Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emscripten issue on runtime - Failed to load 'http://localhost:6931/stdio.html'. #8227

Open
ofTheo opened this issue Dec 8, 2024 · 18 comments

Comments

@ofTheo
Copy link
Member

ofTheo commented Dec 8, 2024

Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:6931/stdio.html'.

After all the other svg / libfmt / texture issues are fixed, I get the above message.
Wonder if it's related to cross domain? or if there is a way to disable?

@Jonathhhan - any idea what this could be related to?

@ofTheo
Copy link
Member Author

ofTheo commented Dec 8, 2024

I see some discussion here:
#8067 which is connected to this issue:

emscripten-core/emscripten#14128

@danoli3
Copy link
Member

danoli3 commented Dec 8, 2024 via email

@Jonathhhan
Copy link
Contributor

Jonathhhan commented Dec 8, 2024

Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:6931/stdio.html'.

After all the other svg / libfmt / texture issues are fixed, I get the above message. Wonder if it's related to cross domain? or if there is a way to disable?

@Jonathhhan - any idea what this could be related to?

@ofTheo Hello.
Sorry, no idea.
This is the error message I get with latest Emscripten and latest OF. Same as yours:

TypeError: Cannot read properties of undefined (reading 'getParameter')
    at _glGetString (index.js:1:147151)
    at index.wasm.ofGLESVersionFromGL(:6931/) (http://localhost:6931/index.wasm)
    at index.wasm.ofTexture::ofTexture(:6931/) (http://localhost:6931/index.wasm)
    at index.wasm.__wasm_call_ctors (index.wasm:0x14614e)
    at callRuntimeCallbacks (index.js:1:13435)
    at initRuntime (index.js:1:8825)
    at doRun (index.js:1:175387)
    at index.js:1:175599

#8211 (comment)
#8219

@Jonathhhan
Copy link
Contributor

Jonathhhan commented Dec 9, 2024

Actually I get the same error after getting rid of the error above (by just returning a 3 as gl version(?)):

Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:6931/stdio.html'.
    at postExit (http://localhost:6931/index.js:7498:12)
    at http://localhost:6931/index.js:7525:11
    at callRuntimeCallbacks (http://localhost:6931/index.js:523:22)
    at exitRuntime (http://localhost:6931/index.js:348:3)
    at exitJS (http://localhost:6931/index.js:4354:5)
    at callMain (http://localhost:6931/index.js:7441:5)
    at doRun (http://localhost:6931/index.js:7466:7)
    at http://localhost:6931/index.js:7473:7

I can only say, that stdio.html seems to be part of emrun:
emscripten-core/emscripten#19776

@dimitre
Copy link
Member

dimitre commented Dec 9, 2024

I'm seeing the next set of errors in apothecary related to ofxOpenCv
sample:

em++: warning: DEMANGLE_SUPPORT is deprecated (mangled names no longer appear in stack traces). Please open a bug if you have a continuing need for this setting [-Wdeprecated]
wasm-ld: error: ../../../addons/obj/emscripten/Debug/ofxOpenCv/src/ofxCvFloatImage.o: undefined symbol: cv::cvarrToMat(void const*, bool, bool, int, cv::AutoBuffer<double, 136ul>*)
wasm-ld: error: ../../../addons/obj/emscripten/Debug/ofxOpenCv/src/ofxCvFloatImage.o: undefined symbol: cv::cvarrToMat(void const*, bool, bool, int, cv::AutoBuffer<double, 136ul>*)
wasm-ld: error: ../../../addons/obj/emscripten/Debug/ofxOpenCv/src/ofxCvGrayscaleImage.o: undefined symbol: cvCreateMat
wasm-ld: error: 

all errors:
https://github.com/openframeworks/openFrameworks/actions/runs/12218984776/job/34103250334

@ofTheo
Copy link
Member Author

ofTheo commented Dec 9, 2024

@danoli3
Copy link
Member

danoli3 commented Dec 9, 2024

I'll check it out again, it was close last time it did work at some point was running so much faster to.

I think the last commit on that PR I still had some issues to fix.
Let me have a look, feeling code like today

@danoli3
Copy link
Member

danoli3 commented Dec 9, 2024

for ref a backup make that might have worked in July:

PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_WEBGPU=1 -s WASM=1
PLATFORM_LDFLAGS += -s MAX_WEBGL_VERSION=2 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s FULL_ES2 -s FULL_ES3=1 
PLATFORM_LDFLAGS += -s AUTO_NATIVE_LIBRARIES=1 -s AUTO_JS_LIBRARIES=1 -s EVAL_CTORS=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s LINKABLE
PLATFORM_LDFLAGS +=  $(PLATFORM_PTHREAD) -s PTHREAD_POOL_SIZE=4
PLATFORM_LDFLAGS += -s PROXY_TO_PTHREAD=1
# PLATFORM_LDFLAGS += -sEXPORTED_FUNCTIONS=_main
# PLATFORM_LDFLAGS += -s WASM_WORKERS=1 -s ENVIRONMENT="web,worker"
# PLATFORM_LDFLAGS += -s USE_GLFW=3 -lglfw
PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js
PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js






# 2 
#--export=__cpp_exception 
PLATFORM_LDFLAGS += --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_WEBGPU=1 -s WASM=1 
PLATFORM_LDFLAGS += -sMIN_WEBGL_VERSION=2 -s USE_WEBGL2=1 -s MAX_WEBGL_VERSION=2  -s FULL_ES2
#PLATFORM_LDFLAGS += -fwasm-exceptions 
PLATFORM_LDFLAGS += -s MINIFY_HTML=0
#PLATFORM_LDFLAGS += -s FILESYSTEM=1 
#-sFORCE_FILESYSTEM=1
PLATFORM_LDFLAGS +=  -sEXPORT_ALL=1
PLATFORM_LDFLAGS +=  -sEXPORT_KEEPALIVE=1
#PLATFORM_LDFLAGS += -s IGNORE_MISSING_MAIN=0  #-s SUPPORT_LONGJMP=wasm 
# PLATFORM_LDFLAGS += -lGL -lhtml5 -lopenal
PLATFORM_LDFLAGS += -s STANDALONE_WASM=1
PLATFORM_LDFLAGS += -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1
PLATFORM_LDFLAGS += -s FULL_ES3=1
PLATFORM_LDFLAGS += -s AUTO_NATIVE_LIBRARIES=1 -s AUTO_JS_LIBRARIES=1 -s EVAL_CTORS=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1
#-sEXCEPTION_CATCHING_ALLOWED=[compile+link] -s EXPORT_EXCEPTION_HANDLING_HELPERS=1 -s EXCEPTION_STACK_TRACES=0
#PLATFORM_LDFLAGS += -s MALLOC=emmalloc
#PLATFORM_LDFLAGS += -sOFFSCREEN_FRAMEBUFFER=1
PLATFORM_LDFLAGS += $(PLATFORM_PTHREAD) -s PTHREAD_POOL_SIZE=4
PLATFORM_LDFLAGS += -sINITIAL_MEMORY=256mb -sSTACK_SIZE=64MB -s EXPORTED_RUNTIME_METHODS=ccall,cwrap,ENV
#PLATFORM_LDFLAGS += -s NO_EXIT_RUNTIME=1
PLATFORM_LDFLAGS += -s VERBOSE=1 

PLATFORM_LDFLAGS += -s EXPORTED_FUNCTIONS="['_main']"
# PLATFORM_LDFLAGS += -s WASM_WORKERS=1 -s ENVIRONMENT="web,worker,node"
PLATFORM_LDFLAGS += -s AUDIO_WORKLET=1

# PLATFORM_LDFLAGS += -s USE_GLFW=3 -lglfw
PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js
PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js

ifdef PROJECT_EMSCRIPTEN_TEMPLATE
	PLATFORM_LDFLAGS += --shell-file $(PROJECT_EMSCRIPTEN_TEMPLATE)
#  else
#  	PLATFORM_LDFLAGS += --shell-file $(OF_LIBS_PATH)/openFrameworksCompiled/project/emscripten/template.html
endif

PLATFORM_OPTIMIZATION_LDFLAGS_RELEASE = -O0  -s VERBOSE=1 -s GL_ASSERTIONS=1 -s ASSERTIONS=1  -gsource-map -s TOTAL_MEMORY=$(PLATFORM_EMSCRIPTEN_TOTAL_MEMORY) -s ALLOW_MEMORY_GROWTH=1

PLATFORM_OPTIMIZATION_LDFLAGS_DEBUG = -O0 -g -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912 							
PLATFORM_OPTIMIZATION_LDFLAGS_DEBUG += -fPIC -s VERBOSE=1 -s GL_ASSERTIONS=1 -s ASSERTIONS=1 

@danoli3
Copy link
Member

danoli3 commented Dec 10, 2024

This is all working now just CSP changes required

@ofTheo
Copy link
Member Author

ofTheo commented Dec 10, 2024 via email

@danoli3
Copy link
Member

danoli3 commented Dec 10, 2024

image

Yeah it even happens locally (thats localhost). Web got real strict !

Solutions: split: Style / script and auto gen index.js. Fixes a lot of the issues.
Then some use of SetTimeout in the core emscripten code which is still problematic

Solution to nonce or hash the file to htaccess we generate. Counter dem hackers hey

@ofTheo
Copy link
Member Author

ofTheo commented Dec 11, 2024

@danoli3 thanks!

I think the goal should be that users can at the least to emrun bin/em/3DPrimitivesExample/ and it just works without needing to setup a local server or anything.

It was until recently, so I am not sure if this is a recent emscripten change or something at the browser level. I Haven't seen any CSP errors but also haven't got past the stdio.html error.

Are you able to push the changes for the stdio.html error?

@ofTheo
Copy link
Member Author

ofTheo commented Dec 13, 2024

Following up on this, it looks like emscripten newer the 3.1.60 has the issues with stdio.html

I think until we can find a solution we should revert apothecary runner and OF/OF to 3.1.50 which has been confirmed to work and then point people to 3.1.50 in the setup guides.

I see this PR was merged, but the emrun / stdio issue was mentioned about not being resolved.
#8067

@danoli3 I tried the above LD flags and they didn't seem to make any difference to the error
@Jonathhhan have you been able to get OF running on >= 3.1.65 locally without the emrun stdio error?

@danoli3
Copy link
Member

danoli3 commented Dec 13, 2024 via email

@ofTheo
Copy link
Member Author

ofTheo commented Dec 13, 2024

Thanks @danoli3
I pulled in your changes and tried them - no errors compiling but nothing on run, just hangs on download with no errors or warnings in Safari / Chrome / Firefox

I think something else is broken in the nightly for emscripten aside from the CORS stuff etc

Going to try an older ofxEmscriptenWindow

image

@danoli3
Copy link
Member

danoli3 commented Dec 14, 2024

PLATFORM_LDFLAGS += -s ASSERTIONS=2
PLATFORM_LDFLAGS += -s GL_ASSERTIONS=1

Also we should implement this GLFW port for our uses:
https://github.com/pongasoft/emscripten-glfw

I had started to but got stuck in the mud with the libs

@danoli3
Copy link
Member

danoli3 commented Dec 14, 2024

index.js:770 wasm streaming compile failed: LinkError: WebAssembly.instantiate(): Import #42 "env" "__assert_fail": function import requires a callable
(anonymous) @ index.js:770Understand this errorAI
index.js:771 falling back to ArrayBuffer instantiation
(anonymous) @ index.js:771Understand this errorAI
index.js:737 failed to asynchronously prepare wasm: LinkError: WebAssembly.instantiate(): Import #42 "env" "__assert_fail": function import requires a callable
(anonymous) @ index.js:737Understand this errorAI
index.js:649 Aborted(LinkError: WebAssembly.instantiate(): Import #42 "env" "__assert_fail": function import requires a callable)
abort @ index.js:649Understand this errorAI
index.js:669 Uncaught (in promise) RuntimeError: Aborted(LinkError: WebAssembly.instantiate(): Import #42 "env" "__assert_fail": function import requires a callable). Build with -sASSERTIONS for more info.
    at abort (index.js:669:11)
    at index.js:739:5Understand this errorAI
    ```

@danoli3
Copy link
Member

danoli3 commented Dec 14, 2024

Due to CSP block it seems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants