KhronosGroup / KhronosGroup/WebGL
Context Restored (webglcontextrestored) - Broken Across Browsers?
- Dominant language
- HTML
- Stars
- 2.9k
- Forks
- 703
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 4
Description
I did some testing on context restored recently and I don't think I understand how and if it's supposed to work anymore.
First off, testing how many contexts I can create, Chrome has a per domain limit. Firefox and Safari have a per page limit. Both seem to have issues.
Chrome: On my Mac chrome seems to have a per domain limit of 16 contexts. If I create 16 in one window and then 1 in another the first window will lose a context. If I then close the second window no context is restored in the first. It's unclear to me how I'd ever get a restored context. I suppose the spec doesn't require a context to ever be restored.
Further, if I lose all references to the contexts I still get a context lost event when the 17th context is created. This is fine, the event listener itself has a reference indirectly. I only bring this up to compare to Firefox below.
Firefox: On my Mac each page has a limit of 16 contexts. If I create 17 all registered to restore then I get into an infinite loop. Creating the 17th context kills the first, the first registered to be restored (calls event.preventDefault), it immediately gets restored which causes another context to get lost, repeat forever.
If I don't keep references to the contexts then Firefox never delievers context lost events (contrast to Chrome above). This is also fine. Since I don't effectively have a reference to the context there's no reason to issue context lost events. Effectively Firefox seems to be doing a forced GC. But, given that AFAIK there is no way to use context restored in Firefox whatsoever. The only way to get it is to create too many contexts in a single page with references to all of them and if you want to restore then you'll get the infinite loop problem. If you don't keep references you'll never get context lost.
I don't really expect browsers to spend any time fix this but if I'm right it might be good to add something to the spec that says "note: webglcontextrestored has no point, don't use it". It seems the best you can do is tell the user "context was lost, click here to refresh" when you get context lost. when the user clicks the page can just create a new context.
Contributor guide
Research direction
No repository file or test is named. Start by reviewing the reported context-loss and context-restoration behavior across Chrome, Firefox, and Safari against the WebGL specification; done would require a decided specification clarification or actionable browser-independent guidance.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics, web-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100