Hi Jukka!
Great to hear from you again :-)
so if you want to see what vanilla emscripten does with context loss, the 
version is here
http://graphics.stanford.edu/~danielh/polarity/opengl/unpatched.html
or you can go to
http://graphics.stanford.edu/~danielh/polarity/opengl/unpatched.html?debug=1
and click "Lose in N calls"

Click those buttons enough and the bugs will surface...
The bugs are of this form:
 exception thrown: TypeError: Cannot set property 'name' of null,TypeError: 
Cannot set property 'name' of null
    at _glGenTextures 
(http://graphics.stanford.edu/~danielh/polarity/opengl/polarity.js:7297:22)
    at __ZN8PolarityL10genTextureEb 
(http://graphics.stanford.edu/~danielh/polarity/opengl/polarity.js:36382:2)
polarity.js:4488 Uncaught TypeError: Cannot set property 'name' of null

where WebGL returns null from something and emscripten immediately 
dereferences it.

Our patch to workaround this is here ( I undid the workaround in the 
unpatched.html repro case above)
https://github.com/cookingclub/polarity/commit/e137337299f8f4b05e8d371f8096c8839a42c2b6
and it simply modifies the canvas to return the last "valid" object when 
there's a context loss. That's clearly a hacky solution but it gets the job 
done.
The real solution is to track down all the places where emscripten assumes 
the returned value from WebGL is not null and returns bogus integers to the 
source program instead

We also noticed a few other bugs including that the TTF_RenderTextSolid 
only allocates a canvas the size of the text, which does not allow for 
things like a "y" or "p" or "g" going below the bottom line and that 
SDL_UnlockSurface simply asserts in OpenGL land (well we had to lock the 
surface to get the text from TTF_RenderTextSolid--I suppose we free it 
straight away) and that TTF_CloseFonts leaks objects instead of deleting 
them from the map...
our master bug list is here:
https://github.com/cookingclub/polarity/blob/master/emscripten_bugs.txt

Hope that helps :-)

On Tuesday, December 30, 2014 7:41:01 AM UTC-8, jj wrote:
>
> Hi Daniel, and nice to hear from you after such a long time!
>
> You're right that a lot of Emscripten WebGL apps leave the context loss 
> handling at the default mode where the shell just says "context lost, 
> please reload the page". I guess for desktop uses this is because the 
> problem so rarely hits the user at the face that people don't bother (or 
> don't even know about it). For mobile applications proper context loss 
> handling is more important, because it happens more often when context 
> switching between apps.
>
> If you have small test cases that you can throw at our way to reproduce 
> the bugs that you find, that would be the easiest.
>
> Tested your page, and works perfectly for me!
>
>    Jukka
>
>
> 2014-12-30 11:32 GMT+02:00 Daniel Horn <[email protected] <javascript:>>
> :
>
>> Hey fine Emscripten folks:
>>
>> I thought you might be interested in a test platform/game a few of my 
>> colleagues and I put together at
>>
>> https://github.com/cookingclub/polarity
>>
>> It's the only open source Emscripten example that deals properly with 
>> context loss and restore
>> as well as having all of SDL1, SDL2, and OpenGL build targets that all 
>> look identical in both WebGL and native under linux.
>> It supports sprite rendering (with scaling, rotation and both per pixel 
>> with per-surface alpha), font rendering and lines.
>>
>> Compiled versions are available here: arrows to move, shift adjusts 
>> polarity:
>> http://graphics.stanford.edu/~danielh/polarity/opengl/
>> and
>> http://graphics.stanford.edu/~danielh/polarity/sdl/
>> and
>> http://graphics.stanford.edu/~danielh/polarity/opengl/?debug=1 if you 
>> want to test Lose WebGL context in N calls
>>
>>
>> We'd love it if anyone was able to use this as a starting point for their 
>> own future projects that were significantly more cross platform than other 
>> examples out there and properly handled context loss.
>>
>> Comments/Suggestions are appreciated!
>>
>> -Daniel
>>
>> PS: emscripten needs a number of simple one-line bug fixes to properly 
>> support context loss and restore and 1 simple fix to support font rendering 
>> under OpenGL.
>> https://github.com/cookingclub/polarity/blob/master/emscripten_bugs.txt
>> Luckily javascript is flexible enough that the bugfixes can be 
>> monkeypatched in during runtime :-) which we do
>> PPS: I hope y'all keep the amazing support for the canvas-based libSDL in 
>> emscripten. It would be unfortunate to require WebGL for graphical 
>> emscripten apps.
>> Or that if y'all go to SDL2 that you make it backed by canvas instead of 
>> WebGL (that's what the OpenGL target is for).
>>
>>
>

-- 
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