Based on the stack trace, that method is called from a JavaScript event
handler, I guess during a sleep. To enable that, you need to add the method
to the YIELDLIST, which is a list of methods that are ok to call during
sleep.

The only other option is for emscripten to automatically delay the event
until after the sleep, I'm not sure if we considered doing that or not, but
in general it seems like it would make events show up later than expected.

- Alon


On Thu, Jun 4, 2015 at 3:54 AM, awt <[email protected]> wrote:

> Hi,
>
> I created a simple SDL2 application with the following pseudo code:
>
> 1. SDL_Init with SDL_INIT_VIDEO
> 2. SDL_CreateWindow
> 3. SDL_CreateRenderer
> 4. IMG_LoadTexture
> 5. SDL_QueryTexture
>
> After this, I try to start up my own message loop in the following manner:
>
> for (;;)
> {
>     while ((1<=SDL_PeepEvents(&e, 1, SDL_GETEVENT, SDL_QUIT,
> SDL_LASTEVENT)))
>     {
>         //If user closes the window
> switch (e.type)
> {
>     case SDL_QUIT:
>     {
>         cout << " SDL_QUIT received!!!";
> quitApp();
> return;
>     }
>     default:
>         break;
> }
>     }
>     emscripten_sleep(10);
> }
>
> But when I click on the window, I get the following assert:
>
> Uncaught abort(-12) at Error
>     at jsStackTrace
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:1325:13)
>     at stackTrace
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:1342:22)
>     at abort
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:33928:44)
>     at Array._Emscripten_HandleMouseFocus
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:22365:54)
>     at dynCall_iiii
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:31705:40)
>     at Object.Runtime.dynCall
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:426:39)
>     at Object.handlerFunc
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:1943:38)
>     at HTMLCanvasElement.jsEventHandler
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:1846:24)
> This error happened during an emterpreter-async save or load of the stack.
> Was there non-emterpreted code on the stack during save (which is
> unallowed)? You may want to adjust EMTERPRETIFY_BLACKLIST,
> EMTERPRETIFY_WHITELIST, or EMTERPRETIFY_YIELDLIST (to consider certain
> functions ok to run during an emscripten_sleep_with_yield).
> This is what the stack looked like when we tried to save it: 1,Error
>     at jsStackTrace
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:1325:13)
>     at stackTrace
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:1342:22)
>     at Object.EmterpreterAsync.handle
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:8744:40)
>     at _emscripten_sleep
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:8767:24)
>     at emterpret
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:13021:6)
>     at Object.emterpret
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:12504:4)
>     at resume
> (file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:8737:17)
>     at
> file:///C:/work/git/SDLPrototypes/EventHandling/src/build/EventHandling.js:8770:11
>
> I find this strange because I am compiling with the following linker flags:
> -s NO_EXIT_RUNTIME=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s
> ASSERTIONS=1 --preload-file image.png -O3 -g3
>
> These are my compiler flags:
> -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s ASSERTIONS=1 -O3 -g3 -D_DEBUG_ -D_DEBUG
>
> Since I did not specify any whitelist, I presume that all the code in my
> generated javascript should already be emterpreted. But somehow,
> _Emscripten_HandleMouseFocus isn't able to handle async states properly as
> this leads to a -12 abort.
>
> Does this mean that I have to manually add all "handle mouse" functions
> into the white or yield list? Or is there a better way around it? I am on
> emsdk 1.30.0.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to