Re: Threading from a Web Worker

2020-09-07 Thread Segmentation Fault Error
To anyone that arrives here: 
It is fixed with this patch -> 
https://github.com/emscripten-core/emscripten/pull/12102 (merge pending), I 
also tested it and it works beautifully!


On Wednesday, August 19, 2020 at 8:32:06 AM UTC+1 Segmentation Fault Error 
wrote:

> Hello,
> in the OP I have a full demo you could check. I also left more info here: 
> https://github.com/emscripten-core/emscripten/issues/11914 
>
> I think I got into this situation by force, since spawning threads from a 
> webworker was not originally working: if you create the Module on your 
> webworker, the thread-workers will start executing your webworker's code 
> which can corrupt its onmessage event (replaced by yours!).
>
> If spawning threads from a webworker is not allowed from the beginning, 
> what alternatives do we have to execute arbitrary threaded-functions that 
> can lock the UI?
>
> On Wednesday, August 19, 2020 at 12:50:42 AM UTC+1 lailto...@gmail.com 
> wrote:
>
>> Segmentation,
>> The update have solved the issue to you? is possible an example code how 
>> are you doing that?
>> Thanks
>>
>> Em terça-feira, 18 de agosto de 2020 às 11:46:17 UTC-3, 
>> segmentation...@gmail.com escreveu:
>>
>>> Oh! Yes, it seems so. Thanks for the link!
>>>
>>> On Tuesday, August 18, 2020 at 3:09:25 PM UTC+1 mehdi...@gmail.com 
>>> wrote:
>>>
 Hi,
 I think there is an issue for this :
 https://github.com/emscripten-core/emscripten/issues/11914


 On Mon, Aug 17, 2020 at 3:42 PM 'Sam Clegg' via emscripten-discuss <
 emscripte...@googlegroups.com> wrote:

>
>
> On Mon, Aug 17, 2020 at 3:28 AM Segmentation Fault Error <
> segmentation...@gmail.com> wrote:
>
>> Should this issue be raised in the emsdk repo? or left aside, until 
>> we have a final release of the threads feature?
>>
>>
> Thread support in emscripten is officially released and available.  
>  If you find bugs then opening a bug in the emscripten repo (not the 
> emsdk 
> repo) is probably the right way to go.
>
> cheers,
> sam
>  
>
>> On Wednesday, July 29, 2020 at 12:26:14 PM UTC+1 Segmentation Fault 
>> Error wrote:
>>
>>> Toying with this concept I realized that some operations cannot be 
>>> performed if you launch a thread from a Web Worker.
>>>
>>> A simpler example, following my setup linked in the OP:
>>>
>>> #include 
>>> #include 
>>> #include 
>>>
>>> void *thread(void *arg) 
>>> {
>>> printf("Hello from thread!\n"); // Execution hangs here if 
>>> Module is instantiated in a Web Worker
>>> return NULL;
>>> }
>>>
>>> EMSCRIPTEN_KEEPALIVE void doSomething() 
>>> {
>>> pthread_t thr;
>>> pthread_create(, NULL, thread, NULL);
>>> }
>>>
>>> To me it seems like it gets locked on spawning threads, IO, ... I 
>>> guess this is not expected behavior, and that this can happen because 
>>> WASM 
>>> threads is a WIP feature. Is there anything else I could do here?
>>>
>>> Cheers,
>>> SFE
>>>
>>> On Friday, July 24, 2020 at 5:35:43 PM UTC+1 alon...@gmail.com 
>>> wrote:
>>>
 Interesting, so this can use pthreads from the main thread ok, but 
 not when starting from a pthread?

 That is a less-tested use case, so it's possible you've run into a 
 bug. Building with -s PTHREADS_DEBUG may help with extra logging. But 
 it 
 may be best to try to reduce this to a small testcase, as it may need 
 to be 
 debugged in depth.

 On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
 segmentation...@gmail.com> wrote:

> Hello everyone,
>
>  
>
> I have been using for a while emscripten to compile a large 
> library. Since its operations take long time, I moved the module to a 
> web 
> worker, where I can call functions without blocking the UI. And it 
> has 
> worked fantastic so far!
>
>  
>
> To further improve performance, I then enabled pthreads in the 
> toolchain. I noticed then that the execution got stuck. Somehow this 
> issue 
> does not occur if the module is executed on the main UI thread, 
> instead of 
> the web worker.
>
>  
>
> I have left a link below, to the demo code on how to reproduce the 
> issue: a function that launches a thread, that launches several 
> threads. It 
> happens that this second level never gets executed if the function 
> was 
> called from a web worker.
>
>  
>
> Maybe I am missing something here, any idea?
>
>  
>
> Regards,
>
> SFE
>
> Link: 
> 

Re: Threading from a Web Worker

2020-08-19 Thread Segmentation Fault Error
Hello,
in the OP I have a full demo you could check. I also left more info here: 
https://github.com/emscripten-core/emscripten/issues/11914 

I think I got into this situation by force, since spawning threads from a 
webworker was not originally working: if you create the Module on your 
webworker, the thread-workers will start executing your webworker's code 
which can corrupt its onmessage event (replaced by yours!).

If spawning threads from a webworker is not allowed from the beginning, 
what alternatives do we have to execute arbitrary threaded-functions that 
can lock the UI?

On Wednesday, August 19, 2020 at 12:50:42 AM UTC+1 lailto...@gmail.com 
wrote:

> Segmentation,
> The update have solved the issue to you? is possible an example code how 
> are you doing that?
> Thanks
>
> Em terça-feira, 18 de agosto de 2020 às 11:46:17 UTC-3, 
> segmentation...@gmail.com escreveu:
>
>> Oh! Yes, it seems so. Thanks for the link!
>>
>> On Tuesday, August 18, 2020 at 3:09:25 PM UTC+1 mehdi...@gmail.com wrote:
>>
>>> Hi,
>>> I think there is an issue for this :
>>> https://github.com/emscripten-core/emscripten/issues/11914
>>>
>>>
>>> On Mon, Aug 17, 2020 at 3:42 PM 'Sam Clegg' via emscripten-discuss <
>>> emscripte...@googlegroups.com> wrote:
>>>


 On Mon, Aug 17, 2020 at 3:28 AM Segmentation Fault Error <
 segmentation...@gmail.com> wrote:

> Should this issue be raised in the emsdk repo? or left aside, until we 
> have a final release of the threads feature?
>
>
 Thread support in emscripten is officially released and available.   If 
 you find bugs then opening a bug in the emscripten repo (not the emsdk 
 repo) is probably the right way to go.

 cheers,
 sam
  

> On Wednesday, July 29, 2020 at 12:26:14 PM UTC+1 Segmentation Fault 
> Error wrote:
>
>> Toying with this concept I realized that some operations cannot be 
>> performed if you launch a thread from a Web Worker.
>>
>> A simpler example, following my setup linked in the OP:
>>
>> #include 
>> #include 
>> #include 
>>
>> void *thread(void *arg) 
>> {
>> printf("Hello from thread!\n"); // Execution hangs here if Module 
>> is instantiated in a Web Worker
>> return NULL;
>> }
>>
>> EMSCRIPTEN_KEEPALIVE void doSomething() 
>> {
>> pthread_t thr;
>> pthread_create(, NULL, thread, NULL);
>> }
>>
>> To me it seems like it gets locked on spawning threads, IO, ... I 
>> guess this is not expected behavior, and that this can happen because 
>> WASM 
>> threads is a WIP feature. Is there anything else I could do here?
>>
>> Cheers,
>> SFE
>>
>> On Friday, July 24, 2020 at 5:35:43 PM UTC+1 alon...@gmail.com wrote:
>>
>>> Interesting, so this can use pthreads from the main thread ok, but 
>>> not when starting from a pthread?
>>>
>>> That is a less-tested use case, so it's possible you've run into a 
>>> bug. Building with -s PTHREADS_DEBUG may help with extra logging. But 
>>> it 
>>> may be best to try to reduce this to a small testcase, as it may need 
>>> to be 
>>> debugged in depth.
>>>
>>> On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
>>> segmentation...@gmail.com> wrote:
>>>
 Hello everyone,

  

 I have been using for a while emscripten to compile a large 
 library. Since its operations take long time, I moved the module to a 
 web 
 worker, where I can call functions without blocking the UI. And it has 
 worked fantastic so far!

  

 To further improve performance, I then enabled pthreads in the 
 toolchain. I noticed then that the execution got stuck. Somehow this 
 issue 
 does not occur if the module is executed on the main UI thread, 
 instead of 
 the web worker.

  

 I have left a link below, to the demo code on how to reproduce the 
 issue: a function that launches a thread, that launches several 
 threads. It 
 happens that this second level never gets executed if the function was 
 called from a web worker.

  

 Maybe I am missing something here, any idea?

  

 Regards,

 SFE

 Link: 
 https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing

 -- 
 You received this message because you are subscribed to the Google 
 Groups "emscripten-discuss" group.
 To unsubscribe from this group and stop receiving emails from it, 
 send an email to emscripten-disc...@googlegroups.com.
 To view this discussion on the web visit 
 

Re: Threading from a Web Worker

2020-08-18 Thread lailto...@gmail.com
Segmentation,
The update have solved the issue to you? is possible an example code how 
are you doing that?
Thanks

Em terça-feira, 18 de agosto de 2020 às 11:46:17 UTC-3, 
segmentation...@gmail.com escreveu:

> Oh! Yes, it seems so. Thanks for the link!
>
> On Tuesday, August 18, 2020 at 3:09:25 PM UTC+1 mehdi...@gmail.com wrote:
>
>> Hi,
>> I think there is an issue for this :
>> https://github.com/emscripten-core/emscripten/issues/11914
>>
>>
>> On Mon, Aug 17, 2020 at 3:42 PM 'Sam Clegg' via emscripten-discuss <
>> emscripte...@googlegroups.com> wrote:
>>
>>>
>>>
>>> On Mon, Aug 17, 2020 at 3:28 AM Segmentation Fault Error <
>>> segmentation...@gmail.com> wrote:
>>>
 Should this issue be raised in the emsdk repo? or left aside, until we 
 have a final release of the threads feature?


>>> Thread support in emscripten is officially released and available.   If 
>>> you find bugs then opening a bug in the emscripten repo (not the emsdk 
>>> repo) is probably the right way to go.
>>>
>>> cheers,
>>> sam
>>>  
>>>
 On Wednesday, July 29, 2020 at 12:26:14 PM UTC+1 Segmentation Fault 
 Error wrote:

> Toying with this concept I realized that some operations cannot be 
> performed if you launch a thread from a Web Worker.
>
> A simpler example, following my setup linked in the OP:
>
> #include 
> #include 
> #include 
>
> void *thread(void *arg) 
> {
> printf("Hello from thread!\n"); // Execution hangs here if Module 
> is instantiated in a Web Worker
> return NULL;
> }
>
> EMSCRIPTEN_KEEPALIVE void doSomething() 
> {
> pthread_t thr;
> pthread_create(, NULL, thread, NULL);
> }
>
> To me it seems like it gets locked on spawning threads, IO, ... I 
> guess this is not expected behavior, and that this can happen because 
> WASM 
> threads is a WIP feature. Is there anything else I could do here?
>
> Cheers,
> SFE
>
> On Friday, July 24, 2020 at 5:35:43 PM UTC+1 alon...@gmail.com wrote:
>
>> Interesting, so this can use pthreads from the main thread ok, but 
>> not when starting from a pthread?
>>
>> That is a less-tested use case, so it's possible you've run into a 
>> bug. Building with -s PTHREADS_DEBUG may help with extra logging. But it 
>> may be best to try to reduce this to a small testcase, as it may need to 
>> be 
>> debugged in depth.
>>
>> On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
>> segmentation...@gmail.com> wrote:
>>
>>> Hello everyone,
>>>
>>>  
>>>
>>> I have been using for a while emscripten to compile a large library. 
>>> Since its operations take long time, I moved the module to a web 
>>> worker, 
>>> where I can call functions without blocking the UI. And it has worked 
>>> fantastic so far!
>>>
>>>  
>>>
>>> To further improve performance, I then enabled pthreads in the 
>>> toolchain. I noticed then that the execution got stuck. Somehow this 
>>> issue 
>>> does not occur if the module is executed on the main UI thread, instead 
>>> of 
>>> the web worker.
>>>
>>>  
>>>
>>> I have left a link below, to the demo code on how to reproduce the 
>>> issue: a function that launches a thread, that launches several 
>>> threads. It 
>>> happens that this second level never gets executed if the function was 
>>> called from a web worker.
>>>
>>>  
>>>
>>> Maybe I am missing something here, any idea?
>>>
>>>  
>>>
>>> Regards,
>>>
>>> SFE
>>>
>>> Link: 
>>> https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, 
>>> send an email to emscripten-disc...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/emscripten-discuss/141a16e4-647e-484c-b36a-8db45addaec8o%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
 You received this message because you are subscribed to the Google 
 Groups "emscripten-discuss" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to emscripten-disc...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/emscripten-discuss/df1255b4-7a74-4b00-9ea7-300ec039c5b6n%40googlegroups.com
  
 

Re: Threading from a Web Worker

2020-08-18 Thread Segmentation Fault Error
Oh! Yes, it seems so. Thanks for the link!

On Tuesday, August 18, 2020 at 3:09:25 PM UTC+1 mehdi...@gmail.com wrote:

> Hi,
> I think there is an issue for this :
> https://github.com/emscripten-core/emscripten/issues/11914
>
>
> On Mon, Aug 17, 2020 at 3:42 PM 'Sam Clegg' via emscripten-discuss <
> emscripte...@googlegroups.com> wrote:
>
>>
>>
>> On Mon, Aug 17, 2020 at 3:28 AM Segmentation Fault Error <
>> segmentation...@gmail.com> wrote:
>>
>>> Should this issue be raised in the emsdk repo? or left aside, until we 
>>> have a final release of the threads feature?
>>>
>>>
>> Thread support in emscripten is officially released and available.   If 
>> you find bugs then opening a bug in the emscripten repo (not the emsdk 
>> repo) is probably the right way to go.
>>
>> cheers,
>> sam
>>  
>>
>>> On Wednesday, July 29, 2020 at 12:26:14 PM UTC+1 Segmentation Fault 
>>> Error wrote:
>>>
 Toying with this concept I realized that some operations cannot be 
 performed if you launch a thread from a Web Worker.

 A simpler example, following my setup linked in the OP:

 #include 
 #include 
 #include 

 void *thread(void *arg) 
 {
 printf("Hello from thread!\n"); // Execution hangs here if Module 
 is instantiated in a Web Worker
 return NULL;
 }

 EMSCRIPTEN_KEEPALIVE void doSomething() 
 {
 pthread_t thr;
 pthread_create(, NULL, thread, NULL);
 }

 To me it seems like it gets locked on spawning threads, IO, ... I guess 
 this is not expected behavior, and that this can happen because WASM 
 threads is a WIP feature. Is there anything else I could do here?

 Cheers,
 SFE

 On Friday, July 24, 2020 at 5:35:43 PM UTC+1 alon...@gmail.com wrote:

> Interesting, so this can use pthreads from the main thread ok, but not 
> when starting from a pthread?
>
> That is a less-tested use case, so it's possible you've run into a 
> bug. Building with -s PTHREADS_DEBUG may help with extra logging. But it 
> may be best to try to reduce this to a small testcase, as it may need to 
> be 
> debugged in depth.
>
> On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
> segmentation...@gmail.com> wrote:
>
>> Hello everyone,
>>
>>  
>>
>> I have been using for a while emscripten to compile a large library. 
>> Since its operations take long time, I moved the module to a web worker, 
>> where I can call functions without blocking the UI. And it has worked 
>> fantastic so far!
>>
>>  
>>
>> To further improve performance, I then enabled pthreads in the 
>> toolchain. I noticed then that the execution got stuck. Somehow this 
>> issue 
>> does not occur if the module is executed on the main UI thread, instead 
>> of 
>> the web worker.
>>
>>  
>>
>> I have left a link below, to the demo code on how to reproduce the 
>> issue: a function that launches a thread, that launches several threads. 
>> It 
>> happens that this second level never gets executed if the function was 
>> called from a web worker.
>>
>>  
>>
>> Maybe I am missing something here, any idea?
>>
>>  
>>
>> Regards,
>>
>> SFE
>>
>> Link: 
>> https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing
>>
>> -- 
>> You received this message because you are subscribed to the Google 
>> Groups "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to emscripten-disc...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/emscripten-discuss/141a16e4-647e-484c-b36a-8db45addaec8o%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to emscripten-disc...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/emscripten-discuss/df1255b4-7a74-4b00-9ea7-300ec039c5b6n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to emscripten-disc...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> 

Re: Threading from a Web Worker

2020-08-17 Thread 'Sam Clegg' via emscripten-discuss
On Mon, Aug 17, 2020 at 3:28 AM Segmentation Fault Error <
segmentation.fault.er...@gmail.com> wrote:

> Should this issue be raised in the emsdk repo? or left aside, until we
> have a final release of the threads feature?
>
>
Thread support in emscripten is officially released and available.   If you
find bugs then opening a bug in the emscripten repo (not the emsdk repo) is
probably the right way to go.

cheers,
sam


> On Wednesday, July 29, 2020 at 12:26:14 PM UTC+1 Segmentation Fault Error
> wrote:
>
>> Toying with this concept I realized that some operations cannot be
>> performed if you launch a thread from a Web Worker.
>>
>> A simpler example, following my setup linked in the OP:
>>
>> #include 
>> #include 
>> #include 
>>
>> void *thread(void *arg)
>> {
>> printf("Hello from thread!\n"); // Execution hangs here if Module is
>> instantiated in a Web Worker
>> return NULL;
>> }
>>
>> EMSCRIPTEN_KEEPALIVE void doSomething()
>> {
>> pthread_t thr;
>> pthread_create(, NULL, thread, NULL);
>> }
>>
>> To me it seems like it gets locked on spawning threads, IO, ... I guess
>> this is not expected behavior, and that this can happen because WASM
>> threads is a WIP feature. Is there anything else I could do here?
>>
>> Cheers,
>> SFE
>>
>> On Friday, July 24, 2020 at 5:35:43 PM UTC+1 alon...@gmail.com wrote:
>>
>>> Interesting, so this can use pthreads from the main thread ok, but not
>>> when starting from a pthread?
>>>
>>> That is a less-tested use case, so it's possible you've run into a bug.
>>> Building with -s PTHREADS_DEBUG may help with extra logging. But it may be
>>> best to try to reduce this to a small testcase, as it may need to be
>>> debugged in depth.
>>>
>>> On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
>>> segmentation...@gmail.com> wrote:
>>>
 Hello everyone,



 I have been using for a while emscripten to compile a large library.
 Since its operations take long time, I moved the module to a web worker,
 where I can call functions without blocking the UI. And it has worked
 fantastic so far!



 To further improve performance, I then enabled pthreads in the
 toolchain. I noticed then that the execution got stuck. Somehow this issue
 does not occur if the module is executed on the main UI thread, instead of
 the web worker.



 I have left a link below, to the demo code on how to reproduce the
 issue: a function that launches a thread, that launches several threads. It
 happens that this second level never gets executed if the function was
 called from a web worker.



 Maybe I am missing something here, any idea?



 Regards,

 SFE

 Link:
 https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing

 --
 You received this message because you are subscribed to the Google
 Groups "emscripten-discuss" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to emscripten-disc...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/emscripten-discuss/141a16e4-647e-484c-b36a-8db45addaec8o%40googlegroups.com
 
 .

>>> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/df1255b4-7a74-4b00-9ea7-300ec039c5b6n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAL_va2-jXJingg7HZehLFFtBG24dT0uijNUo0J%2BZhbq-YKPf6w%40mail.gmail.com.


Re: Threading from a Web Worker

2020-08-17 Thread Segmentation Fault Error
Should this issue be raised in the emsdk repo? or left aside, until we have 
a final release of the threads feature?

On Wednesday, July 29, 2020 at 12:26:14 PM UTC+1 Segmentation Fault Error 
wrote:

> Toying with this concept I realized that some operations cannot be 
> performed if you launch a thread from a Web Worker.
>
> A simpler example, following my setup linked in the OP:
>
> #include 
> #include 
> #include 
>
> void *thread(void *arg) 
> {
> printf("Hello from thread!\n"); // Execution hangs here if Module is 
> instantiated in a Web Worker
> return NULL;
> }
>
> EMSCRIPTEN_KEEPALIVE void doSomething() 
> {
> pthread_t thr;
> pthread_create(, NULL, thread, NULL);
> }
>
> To me it seems like it gets locked on spawning threads, IO, ... I guess 
> this is not expected behavior, and that this can happen because WASM 
> threads is a WIP feature. Is there anything else I could do here?
>
> Cheers,
> SFE
>
> On Friday, July 24, 2020 at 5:35:43 PM UTC+1 alon...@gmail.com wrote:
>
>> Interesting, so this can use pthreads from the main thread ok, but not 
>> when starting from a pthread?
>>
>> That is a less-tested use case, so it's possible you've run into a bug. 
>> Building with -s PTHREADS_DEBUG may help with extra logging. But it may be 
>> best to try to reduce this to a small testcase, as it may need to be 
>> debugged in depth.
>>
>> On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
>> segmentation...@gmail.com> wrote:
>>
>>> Hello everyone,
>>>
>>>  
>>>
>>> I have been using for a while emscripten to compile a large library. 
>>> Since its operations take long time, I moved the module to a web worker, 
>>> where I can call functions without blocking the UI. And it has worked 
>>> fantastic so far!
>>>
>>>  
>>>
>>> To further improve performance, I then enabled pthreads in the 
>>> toolchain. I noticed then that the execution got stuck. Somehow this issue 
>>> does not occur if the module is executed on the main UI thread, instead of 
>>> the web worker.
>>>
>>>  
>>>
>>> I have left a link below, to the demo code on how to reproduce the 
>>> issue: a function that launches a thread, that launches several threads. It 
>>> happens that this second level never gets executed if the function was 
>>> called from a web worker.
>>>
>>>  
>>>
>>> Maybe I am missing something here, any idea?
>>>
>>>  
>>>
>>> Regards,
>>>
>>> SFE
>>>
>>> Link: 
>>> https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to emscripten-disc...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/emscripten-discuss/141a16e4-647e-484c-b36a-8db45addaec8o%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/df1255b4-7a74-4b00-9ea7-300ec039c5b6n%40googlegroups.com.


Re: Threading from a Web Worker

2020-07-29 Thread Segmentation Fault Error
Toying with this concept I realized that some operations cannot be 
performed if you launch a thread from a Web Worker.

A simpler example, following my setup linked in the OP:

#include 
#include 
#include 

void *thread(void *arg) 
{
printf("Hello from thread!\n"); // Execution hangs here if Module is 
instantiated in a Web Worker
return NULL;
}

EMSCRIPTEN_KEEPALIVE void doSomething() 
{
pthread_t thr;
pthread_create(, NULL, thread, NULL);
}

To me it seems like it gets locked on spawning threads, IO, ... I guess 
this is not expected behavior, and that this can happen because WASM 
threads is a WIP feature. Is there anything else I could do here?

Cheers,
SFE

On Friday, July 24, 2020 at 5:35:43 PM UTC+1 alon...@gmail.com wrote:

> Interesting, so this can use pthreads from the main thread ok, but not 
> when starting from a pthread?
>
> That is a less-tested use case, so it's possible you've run into a bug. 
> Building with -s PTHREADS_DEBUG may help with extra logging. But it may be 
> best to try to reduce this to a small testcase, as it may need to be 
> debugged in depth.
>
> On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
> segmentation...@gmail.com> wrote:
>
>> Hello everyone,
>>
>>  
>>
>> I have been using for a while emscripten to compile a large library. 
>> Since its operations take long time, I moved the module to a web worker, 
>> where I can call functions without blocking the UI. And it has worked 
>> fantastic so far!
>>
>>  
>>
>> To further improve performance, I then enabled pthreads in the toolchain. 
>> I noticed then that the execution got stuck. Somehow this issue does not 
>> occur if the module is executed on the main UI thread, instead of the web 
>> worker.
>>
>>  
>>
>> I have left a link below, to the demo code on how to reproduce the issue: 
>> a function that launches a thread, that launches several threads. It 
>> happens that this second level never gets executed if the function was 
>> called from a web worker.
>>
>>  
>>
>> Maybe I am missing something here, any idea?
>>
>>  
>>
>> Regards,
>>
>> SFE
>>
>> Link: 
>> https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to emscripten-disc...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/emscripten-discuss/141a16e4-647e-484c-b36a-8db45addaec8o%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/71922739-0935-4b4d-b4c2-ee4c0067cd44n%40googlegroups.com.


Re: Threading from a Web Worker

2020-07-24 Thread Alon Zakai
Interesting, so this can use pthreads from the main thread ok, but not when
starting from a pthread?

That is a less-tested use case, so it's possible you've run into a bug.
Building with -s PTHREADS_DEBUG may help with extra logging. But it may be
best to try to reduce this to a small testcase, as it may need to be
debugged in depth.

On Thu, Jul 23, 2020 at 7:46 AM Segmentation Fault Error <
segmentation.fault.er...@gmail.com> wrote:

> Hello everyone,
>
>
>
> I have been using for a while emscripten to compile a large library. Since
> its operations take long time, I moved the module to a web worker, where I
> can call functions without blocking the UI. And it has worked fantastic so
> far!
>
>
>
> To further improve performance, I then enabled pthreads in the toolchain.
> I noticed then that the execution got stuck. Somehow this issue does not
> occur if the module is executed on the main UI thread, instead of the web
> worker.
>
>
>
> I have left a link below, to the demo code on how to reproduce the issue:
> a function that launches a thread, that launches several threads. It
> happens that this second level never gets executed if the function was
> called from a web worker.
>
>
>
> Maybe I am missing something here, any idea?
>
>
>
> Regards,
>
> SFE
>
> Link:
> https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/141a16e4-647e-484c-b36a-8db45addaec8o%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpTp2Zjoc_OfVO9z2Sq4x1mGDh8PenYO7EJdT%3DOeAv12sA%40mail.gmail.com.


Threading from a Web Worker

2020-07-23 Thread Segmentation Fault Error
 

Hello everyone,

 

I have been using for a while emscripten to compile a large library. Since 
its operations take long time, I moved the module to a web worker, where I 
can call functions without blocking the UI. And it has worked fantastic so 
far!

 

To further improve performance, I then enabled pthreads in the toolchain. I 
noticed then that the execution got stuck. Somehow this issue does not 
occur if the module is executed on the main UI thread, instead of the web 
worker.

 

I have left a link below, to the demo code on how to reproduce the issue: a 
function that launches a thread, that launches several threads. It happens 
that this second level never gets executed if the function was called from 
a web worker.

 

Maybe I am missing something here, any idea?

 

Regards,

SFE

Link: 
https://drive.google.com/file/d/1EtkdRBN1Y8QpsRE19BH5AePAD3VLAV6U/view?usp=sharing

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/141a16e4-647e-484c-b36a-8db45addaec8o%40googlegroups.com.