emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.77k stars 3.3k forks source link

Exception When Calling "emscripten_request_fullscreen" on iOS Firefox Only. Fails to go into Fullscreen Mode. #19735

Open cybereality opened 1 year ago

cybereality commented 1 year ago

I am using OpenGL and SDL2 with emscripten, and when calling the function emscripten_request_fullscreen("canvas", true); it results in an exception on Firefox iOS only. The canvas does not go fullscreen and no OS messages indicate the fullscreen mode has been successful. Safari and Chrome on iOS work fine. Firefox and Chrome work fine on Android. All desktop systems and browsers are fine. I put an exception handler in the Javascript, however the exception is null and provides no information. Unfortunately I cannot find a way to remote debug Firefox on iOS, so I'm not sure how to get any other information. I've created a minimum reproduction project, which you can see below (after I click on the canvas to go fullscreen). Note that emscripten_request_fullscreen_strategy also has similar problems, depending on which settings you use, but none of them work on Firefox iOS.

Firefox_iOS

SimpleScreen.zip

You can just use the command make to compile or look in the make file, I don't think there is much unique there.

Any help would be appreciated.

Version of emscripten/emsdk: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.34 (57b21b8fdcbe3ebb523178b79465254668eab408) clang version 17.0.0 (https://github.com/llvm/llvm-project a031f72187ce495b9faa4ccf99b1e901a3872f4b) Target: wasm32-unknown-emscripten Thread model: posix

Failing command line in full: Compiles fine.

Full link command and output with -v appended: emcc -O2 main.cpp -s USE_SDL=2 -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2 -s FULL_ES3=1 -s ALLOW_MEMORY_GROWTH -s NO_DISABLE_EXCEPTION_CATCHING -v -o index.html --shell-file simple.html "/media/cybereality/Thrive/SDK/emsdk/upstream/bin/clang" --version "/media/cybereality/Thrive/SDK/emsdk/upstream/bin/clang++" -target wasm32-unknown-emscripten -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -I/media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/SDL2 --sysroot=/media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -O2 -v main.cpp -c -o /tmp/emscripten_temp_2zqywp51/main_0.o clang version 17.0.0 (https://github.com/llvm/llvm-project a031f72187ce495b9faa4ccf99b1e901a3872f4b) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /media/cybereality/Thrive/SDK/emsdk/upstream/bin (in-process) "/media/cybereality/Thrive/SDK/emsdk/upstream/bin/clang-17" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/media/cybereality/Thrive/Projects/OpenGL/SimpleScreen -resource-dir /media/cybereality/Thrive/SDK/emsdk/upstream/lib/clang/17 -D EMSCRIPTEN -I /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/SDL2 -isysroot /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /media/cybereality/Thrive/SDK/emsdk/upstream/lib/clang/17/include -internal-isystem /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include -O2 -fdeprecated-macro -fdebug-compilation-dir=/media/cybereality/Thrive/Projects/OpenGL/SimpleScreen -ferror-limit 19 -fvisibility=default -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_2zqywp51/main_0.o -x c++ main.cpp clang -cc1 version 17.0.0 based upon LLVM 17.0.0git default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1" ignoring nonexistent directory "/media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"

include "..." search starts here:

include <...> search starts here:

/media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/SDL2 /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/compat /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 /media/cybereality/Thrive/SDK/emsdk/upstream/lib/clang/17/include /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/include End of search list. "/media/cybereality/Thrive/SDK/emsdk/upstream/bin/wasm-ld" -o index.wasm /tmp/emscripten_temp_2zqywp51/main_0.o -L/media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libSDL2.a -lGL-webgl2-full_es3 -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++ -lc++abi -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined-file=/tmp/tmp8lfn2wz0.undefined --strip-debug --export-if-defined=main --export-if-defined=start_em_asm --export-if-defined=stop_em_asm --export-if-defined=start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=start_em_js --export-if-defined=stop_em_js --export-if-defined=main_argc_argv --export=stackSave --export=stackRestore --export=stackAlloc --export=errno_location --export=getTempRet0 --export=setTempRet0 --export=get_temp_ret --export=set_temp_ret --export=__cxa_is_pointer_type --export=cxa_can_catch --export=setThrew --export=cxa_free_exception --export=wasm_call_ctors --export=malloc --export=free --export=__dl_seterr --export=memcpy --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=2147483648 --global-base=1024 "/media/cybereality/Thrive/SDK/emsdk/upstream/bin/wasm-emscripten-finalize" --dyncalls-i64 --pass-arg=legalize-js-interface-exported-helpers index.wasm -o index.wasm --detect-features "/media/cybereality/Thrive/SDK/emsdk/node/14.18.2_64bit/bin/node" /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/src/compiler.js /tmp/tmpvysmeb0x.json "/media/cybereality/Thrive/SDK/emsdk/upstream/bin/wasm-opt" --strip-dwarf --post-emscripten -O2 --low-memory-unused --zero-filled-memory --pass-arg=directize-initial-contents-immutable --strip-debug --strip-producers index.wasm -o index.wasm --mvp-features --enable-mutable-globals --enable-sign-ext "/media/cybereality/Thrive/SDK/emsdk/node/14.18.2_64bit/bin/node" /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/tools/acorn-optimizer.js /tmp/emscripten_temp_2zqywp51/index.js JSDCE minifyWhitespace -o /tmp/emscripten_temp_2zqywp51/index.jso1.js "/media/cybereality/Thrive/SDK/emsdk/node/14.18.2_64bit/bin/node" /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/tools/preprocessor.js /tmp/emscripten_temp_2zqywp51/settings.js simple.html "/media/cybereality/Thrive/SDK/emsdk/node/14.18.2_64bit/bin/node" /media/cybereality/Thrive/SDK/emsdk/upstream/emscripten/node_modules/.bin/html-minifier-terser index.html -o index.html --collapse-whitespace --collapse-inline-tag-whitespace --remove-comments --remove-tag-whitespace --sort-attributes --sort-class-name --decode-entities --collapse-boolean-attributes --remove-attribute-quotes --remove-redundant-attributes --remove-script-type-attributes --remove-style-link-type-attributes --use-short-doctype --minify-css true --minify-js true

sbc100 commented 1 year ago

Is there some way you could share the full backtrace from the JS console?

cybereality commented 1 year ago

I can't because I'm not able to remote debug on Firefox iOS. As far as I can tell, only Safari works (when you use a macOS desktop).

sbc100 commented 1 year ago

Perhaps you could report the .stack of the exception ?

cybereality commented 1 year ago

It says "undefined"

sbc100 commented 1 year ago

I'm not sure I can offer more advice other than trying to figure out how to attach a remove debugger to FF on iOS.. presumably its not impossible? (Folks here seem to doing it: https://discourse.mozilla.org/t/how-do-i-debug-firefox-on-ios/111414)

cybereality commented 1 year ago

I did see that, but it doesn't seem to work anymore.

cybereality commented 1 year ago

Okay, so I did more testing and I've determined it's a bug in Firefox iOS with the function requestFullscreen it has nothing to do with emscripten. I've attached a minimum reproduction project in case this helps anyone finding this bug.

FirefoxFull.zip

I'm going to contact Mozilla and follow up with this. I guess I can leave this open for now, so I can update with information or a fix if they get back to me. Thanks.

cybereality commented 1 year ago

https://github.com/mozilla-mobile/firefox-ios/issues/15253