mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-12 01:14:01 +00:00
Restore on webgl context loss (#3968)
## Description: When WebGL context is lost, restore context and all elements. In GameView, handle potentially transient undefined states during context loss gracefully. Test with chrome://gpucrash from another tab, then return to the game tab to see it being restored (This fake gpucrash only works once sometimes. Because the second time the browser might reject the tab it thinks caused the gpu crash, access to hardware acceleration. And after even more tries even disables it browser-wide. A browser restart resets it in that case.) ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33
This commit is contained in:
@@ -43,6 +43,12 @@ export class WebGLFrameBuilder {
|
||||
this.patternData = new Uint8Array(PALETTE_SIZE * 1024);
|
||||
}
|
||||
|
||||
/** Drop internal caches to force a full re-upload of state on the next update(). */
|
||||
clearCaches(): void {
|
||||
this.knownSmallIDs.clear();
|
||||
this.localPlayerSmallID = 0;
|
||||
}
|
||||
|
||||
update(gameView: GameView): void {
|
||||
this.syncPlayers(gameView);
|
||||
this.syncLocalPlayer(gameView);
|
||||
|
||||
Reference in New Issue
Block a user