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

Can't edit any text input fields on my page with Emscripten's .js file loaded. #22947

Open
inhahe opened this issue Nov 16, 2024 · 14 comments
Open

Comments

@inhahe
Copy link

inhahe commented Nov 16, 2024

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.71 (4171ae200b77a6c266b0e1ebb507d61d1ade3501)
clang version 20.0.0git (https:/github.com/llvm/llvm-project d6344c1cd0d099f8d99ee320f33fc9254dbe8288)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/inhahe/emsdk/upstream/bin

Full link command and output with -v appended:

(base) inhahe@Logoplex3:/mnt/d/visual studio projects/scribbles3$ em++ /mnt/d/visual\ studio\ projects/scribbles3/wasm.cpp -s WASM=1 -s USE_SDL=2 -o wasm.js -sALLOW_MEMORY_GROWTH -v
 "/home/inhahe/emsdk/upstream/bin/clang++" -target wasm32-unknown-emscripten -fignore-exceptions -mno-bulk-memory -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/home/inhahe/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -isystem /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/SDL2 -Xclang -iwithsysroot/include/compat -v "/mnt/d/visual studio projects/scribbles3/wasm.cpp" -c -o /tmp/emscripten_temp_foz7x5b0/wasm_0.o
clang version 20.0.0git (https:/github.com/llvm/llvm-project d6344c1cd0d099f8d99ee320f33fc9254dbe8288)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/inhahe/emsdk/upstream/bin
 (in-process)
 "/home/inhahe/emsdk/upstream/bin/clang-20" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name wasm.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature -bulk-memory -target-feature -nontrapping-fptoint -fvisibility=hidden -debugger-tuning=gdb "-fdebug-compilation-dir=/mnt/d/visual studio projects/scribbles3" -v "-fcoverage-compilation-dir=/mnt/d/visual studio projects/scribbles3" -resource-dir /home/inhahe/emsdk/upstream/lib/clang/20 -isystem /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/SDL2 -D EMSCRIPTEN -isysroot /home/inhahe/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /home/inhahe/emsdk/upstream/lib/clang/20/include -internal-isystem /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_foz7x5b0/wasm_0.o -x c++ "/mnt/d/visual studio projects/scribbles3/wasm.cpp"
clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/SDL2
 /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/compat
 /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
 /home/inhahe/emsdk/upstream/lib/clang/20/include
 /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
 /home/inhahe/emsdk/upstream/bin/clang --version
 /home/inhahe/emsdk/upstream/bin/wasm-ld -o wasm.wasm /tmp/emscripten_temp_foz7x5b0/wasm_0.o -L/home/inhahe/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /home/inhahe/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libSDL2.a -lGL-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmpfzjsqcj7libemscripten_js_symbols.so --strip-debug --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=_emscripten_stack_alloc --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export=_emscripten_stack_restore --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 --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --max-memory=2147483648 --initial-heap=16777216 --no-entry --stack-first --table-base=1
 /home/inhahe/emsdk/upstream/bin/llvm-objcopy wasm.wasm wasm.wasm --remove-section=.debug* --remove-section=producers
 /home/inhahe/emsdk/upstream/bin/wasm-emscripten-finalize --dyncalls-i64 --pass-arg=legalize-js-interface-exported-helpers wasm.wasm -o wasm.wasm --detect-features
 /home/inhahe/emsdk/node/20.18.0_64bit/bin/node /home/inhahe/emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmp3jh_xba_.json

So, here's a minimal html file that exhibits this behavior. I didn't even include the canvas object or anything for simplicity, but rest assured the problem persists even if it's a full proper web app.

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>
  <body>
    <input type="text" />
    <script src="index.js"></script>
  </body>
</html>

I tried it using two different compiled .cpp files, one of them was rather small.

Please help me, Emscripten's js file is way too complicated for me to debug. ;p

@inhahe
Copy link
Author

inhahe commented Nov 16, 2024

I just confirmed that the problem is also there if my em++ target is the .html file (edited to add an input field) rather than the .js file with the custom html.

@sbc100
Copy link
Collaborator

sbc100 commented Nov 18, 2024

I believe this will be fixed by: #22879, and is likely a duplicate of #22866

@inhahe
Copy link
Author

inhahe commented Nov 18, 2024

@sbc100 Thanks. When you say "this will be fixed by," do you mean there's a fix for it somewhere in the thread, or do you mean Emscripten is planning on fixing the issue but hasn't yet?
I updated Emscripted with git pull and recompiled my program, and I'm still getting the issue.
How do I apply the fix? Is it that 'no space' comment about the one js file? Or is it the approved commit shown at the bottom? Do I have to pull that commit somehow?

@uysalibov
Copy link

@inhahe I created a PR because I had a similar problem. It has not been merged yet. If you follow the relevant PR, your problem should be solved when it is merged.

@inhahe
Copy link
Author

inhahe commented Nov 18, 2024

@uysalibov Oh, I see, thanks. Can you tell me how to follow the PR? I can't find a button to do that.

@inhahe
Copy link
Author

inhahe commented Nov 18, 2024

@uysalibov Hmm, I did gh pr checkout 22879 according to the 'Code' pulldown to see if that would fix the problem, and it doesn't seem to have fixed it.

Edit: I just tried it again and got GraphQL: Could not resolve to a PullRequest with the number of 22879. (repository.pullRequest)

@uysalibov
Copy link

@uysalibov Oh, I see, thanks. Can you tell me how to follow the PR? I can't find a button to do that.

There is a subscribe button on the rightside.

Edit: I just tried it again and got GraphQL: Could not resolve to a PullRequest with the number of 22879. (repository.pullRequest)

Probably this error is related about gh client. I don't think it's about related PR

@inhahe
Copy link
Author

inhahe commented Nov 18, 2024

@uysalibov Oh, I see, thanks. Can you tell me how to follow the PR? I can't find a button to do that.

There is a subscribe button on the rightside.

Thanks. The problem was I was on https://github.com/emscripten-core/emscripten/pull/22879/files instead of #22879.

Edit: I just tried it again and got GraphQL: Could not resolve to a PullRequest with the number of 22879. (repository.pullRequest)

Probably this error is related about gh client. I don't think it's about related PR

Hmm, is there another way to pull the commit than gh?

@inhahe
Copy link
Author

inhahe commented Nov 18, 2024

I believe this will be fixed by: #22879, and is likely a duplicate of #22866

I couldn't figure out how to pull the commit, so I just viewed the two js files and copied and replaced the original files with the new ones and then recompiled my program, and the problem didn't go away. ;/

@sbc100
Copy link
Collaborator

sbc100 commented Nov 18, 2024

Oh, I think #22879 only fixes the issue for GLFW and SDL programs, not SDL2 programs. @Daft-Freak do you know if SDL2 suffers from the same issue, and can/should we apply a similar fix there?

@Daft-Freak
Copy link
Collaborator

Daft-Freak commented Nov 18, 2024

Doing the same in SDL2 would be more difficult as we don't have access to event.target from C...

There are the workarounds of disabling SDL_TEXTINPUT events or using the keyboard element hint there though.

EDIT: That would need to be SDL_KEYDOWN disabled or filtered not SDL_TEXTINPUT I think.

@inhahe
Copy link
Author

inhahe commented Nov 19, 2024

@sbc100 Not sure if this is a problem with your code or if I did something wrong, but I did
em++ /mnt/d/visual\ studio\ projects/scribbles3/em.cpp -s WASM=1 -s -o em.js -sALLOW_MEMORY_GROWTH -Oz -'sEXPORTED_FUNCTIONS=_getpixels,_mainloop
And got

cache:INFO: generating system asset: symbol_lists/3d96c02f75df7abfb22642729420d3b90ef03869.json... (this will be cached in "/home/inhahe/emsdk/upstream/emscripten/cache/symbol_lists/3d96c02f75df7abfb22642729420d3b90ef03869.json" for subsequent builds)
error: library_sdl.js: failure to execute js library "library_sdl.js":
error: library_sdl.js: use -sVERBOSE to see more details
Internal compiler error in src/compiler.mjs!
Please create a bug report at https://github.com/emscripten-core/emscripten/issues/
with a log of the build and the input files used to run. Exception message: "file:///home/inhahe/emsdk/upstream/emscripten/src/modules.mjs:327
      throw new Error(
      ^

Error: Missing C define SDL_HWSURFACE! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)
    at Object.get (file:///home/inhahe/emsdk/upstream/emscripten/src/modules.mjs:327:13)
    at library_sdl.js:1:8
    at Script.runInContext (node:vm:149:12)
    at Module.runInContext (node:vm:301:6)
    at runInMacroContext (file:///home/inhahe/emsdk/upstream/emscripten/src/utility.mjs:333:13)
    at file:///home/inhahe/emsdk/upstream/emscripten/src/parseTools.mjs:37:17
    at String.replace (<anonymous>)
    at processMacros (file:///home/inhahe/emsdk/upstream/emscripten/src/parseTools.mjs:36:15)
    at Object.load (file:///home/inhahe/emsdk/upstream/emscripten/src/modules.mjs:248:21)
    at Module.runJSify (file:///home/inhahe/emsdk/upstream/emscripten/src/jsifier.mjs:169:18)
em++: error: '/home/inhahe/emsdk/node/20.18.0_64bit/bin/node /home/inhahe/emsdk/upstream/emscripten/src/compiler.mjs /tmp/tmpci6enfia.json --symbols-only' failed (returned 1)

After having copied your modified file into emsdk/upstream/emscripten/src/

I may have done a git pull after having copied your file, that could be what did it, because I was able to compile after copying the file before..

@uysalibov
Copy link

uysalibov commented Nov 19, 2024

You shouldn't copy all modified file. You just need to change related lines. There may be other pr's merged before this pr. You lose them

@inhahe
Copy link
Author

inhahe commented Nov 19, 2024

You shouldn't copy all modified file. You just need to change related lines. There may be other pr's merged before this pr. You lose them

Oh, I get it, thanks. That makes sense.

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