New issue
Advanced search Search tips

Issue 861765 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Aug 17
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 857476



Sign in to add a comment

Some non-crash oddities with a Wasm Threads example.

Project Member Reported by hablich@chromium.org, Jul 9

Issue description

Follow-up of 857049

I installed emscripten and did:

1.) Example code from http://timmurphy.org/2010/05/04/pthreads-in-c-a-minimal-working-example/
2.) Compiled it via emscripten by 'emcc -s USE_PTHREADS=1 -s WASM=1 -o threads.html threads.c'
3.) Enabled chrome://flags/#enable-webassembly-threads
4.) Hosted threads.html via 'python -m SimpleHTTPServer"
5.) Opened file on Mac Canary 69.0.3486.0 (Official Build) canary (64-bit)
6.) Page opens and spinner starts with "Downloading"
7.) Page unresponsive popup appears
8.) Click Wait
9.) Open DevTools to analyze the problem
10.) Spinner freezes, no output on the console, nothing in sources
11.) Chrome Task Manager shows the tab at 100 % CPU usage
12.) Killing the process via the Chrome task manager crashes the tab
13.) Hit Reload on the sad tab page (DevTools still open)
14.) Spinner still stuck at "Downloading" but the DevTools console now shows something meaningful: "wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssebmly': Incorrect response MIME type. Expected 'application/wasm'.". Maybe Python's SimpleHTTPServer simply do not support serving Wasm correctly?

Emscripten version is 'emcc (Emscripten gcc/clang-like replacement) 1.38.6 (commit 8512c60588d566bb325b57ef55443ce87492e2b4)'

It is very likely that my compiled example is broken, but I would assume that shouldn't produce mentioned result. Instead there should be some feedback to the developer that something and what is broken.


If I compile with 'emcc -s USE_PTHREADS=1 -s PHTREAD_POOL_SIZE=2 -s WASM=1 -o threads.html threads.c' the program seems to work correctly btw. The output is correctly plotted to the simulated printf console, which was not the case with the other configuration. The CPU usage goes back to 0 %. The streaming compile error is still plotted to the DevTools console though.

 
Might be intended behavior according to https://kripken.github.io/emscripten-site/docs/porting/pthreads.html:

"When the linker flag -s PTHREAD_POOL_SIZE=<integer> is not specified and pthread_create() is called, the new thread will not actually start to run immediately, but the main JS thread must yield execution back to browser first. This behavior is a result of #1049079."
Cc: -ahaas@chromium.org clemensh@chromium.org
Owner: ahaas@chromium.org
Status: Assigned (was: Untriaged)
Hi Michael, Could you add the compiled code here so that it's easier to reproduce? Thanks!
Sure thing. 
threads.tar
490 KB Download
Status: WontFix (was: Assigned)
I think I don't understand this issue. What behavior would you expect, and what behavior do you get? For me the page does not get unresponsive. However, the page does not show much, only "Preallocating 2 workers for a pthread spawn pool." in the console, and the spinner at the top saying "All downloads complete".

I think there is nothing to do here. please reopen the bug if I am wrong.
Sorry for not being clear. The issue was 10.): DevTools didn't seem to be working. This is working now though. It seems we use a PTHREAD_POOL_SIZE is ignored and we spawn threads a appropriate?

On Canary I always get "Preallocating 2 workers for a pthread spawn pool." even when setting PTHREAD_POOL_SIZE to something else.
As far as I understand the code in threads.tar of #3, in threads.js in line 1423 exactly 2 workers get created. This looks like generated code to me. So I think what you see is working as intended.

Sign in to add a comment