emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.63k stars 3.28k forks source link

SDL.surfaces.ctx has no save function #15934

Open ghost opened 2 years ago

ghost commented 2 years ago

Please include the following in your bug report:

Version of emscripten/emsdk: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.1-git (e325125379a98b0bc2988a6de8ad7f54191ade34) clang version 14.0.0 (https://github.com/llvm/llvm-project 1a929525e86a20d0b3455a400d0dbed40b325a13) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /Users/pro21/emsdk/upstream/bin

Failing command line in full: no failing command line

Full link command and output with -v appended: no failing command line

when i run the sdl test ,say "sdl_canvas.c", I run this command :

./emcc tests/sdl_canvas.c -s USE_FREETYPE=1 -s FETCH=1 --proxy-to-worker -o hello.html

and i get this error from the browser' console when i open hello.html:

hello.js:5850 Uncaught TypeError: surfData.ctx.save is not a function
    at _SDL_FillRect (hello.js:5850)
    at 00018492:0x684
    at hello.js:1551
    at callMain (hello.js:8708)
    at doRun (hello.js:8765)
    at hello.js:8776

this is the screen snapshot, image

sbc100 commented 2 years ago

Most likely --proxy-to-worker doesn't work with surface/canvas like this. We have OFFSCREENCANVAS_SUPPORT and OFFSCREEN_FRAMEBUFFER that are worth looking into but I don't know if they work with --proxy-to-worker.

@juj would know more.

We should probably give a more useful error..

juj commented 2 years ago

Sorry, I never worked with the SDL 1.4 JS library, except to submit some bugfixes. When I wrote OffscreenCanvas support and the Offscreen Framebuffer support, neither of those were developed with this SDL 1.4 library in mind.

Neither the OffscreenCanvas or Offscreen Framebuffer features can work with --proxy-to-worker, because they both require bootstrapping wasm code to execute on the main browser thread. (with OffscreenCanvas one could create a manual shim on the main browser thread to do the passing of the canvas over to the worker, if someone is interested in developing that)