fix(web): fix Android Chrome black screen and Fixed-mode WebGL2 viewport scissor
Resolves the Android Chrome black screen after closing the welcome back interface and prevents Fixed-mode 317HD `gl.clear` from wiping surrounding HUD/border regions. ### WebGL2 Context & Fixed-Mode Scissoring - `WebGL2.java`: - Enabled `preserveDrawingBuffer: true` and removed `desynchronized: true` on the `#gl-canvas` WebGL2 context to prevent Android Chrome from clearing or failing to composite between frames. - Added `SCISSOR_TEST` (`0x0C11`) and `scissor(x, y, width, height)` bindings. - `WebHd317Renderer.java`: - Wrapped Pass 2 (`gl.clear` and 3D scene draw) in `GL_SCISSOR_TEST` (`gl.scissor(vpX, vpY, width, height)`) so Fixed-mode stone borders, chatbox, and tab areas are preserved. - Reused `HD317Pipeline.backend` in `ensureOverlayReady()` to avoid creating duplicate `WebHd317Renderer` instances. - `RSImageProducer.java`: - Removed `desynchronized: true` from `#game-canvas`'s 2D context so Android Chrome composites `#game-canvas` transparently over `#gl-canvas`. ### Service Worker Caching - `src/main/webapp/sw.js`: - Bumped `CACHE_VERSION` to `2006scape-web-v3` and switched `js/client.js` to network-first (with cache fallback) so client updates take effect immediately when online.
This commit is contained in:
1 parent
ededb882a0
commit
4bcb91c3a2
4 files changed
+19
-7
No files matched your search
@@ -55,7 +55,7 @@ public final class RSImageProducer {
|
||||
}
|
||||
|
||||
@JSBody(params = {"canvas"}, script =
|
||||
"try { return canvas.getContext('2d', { alpha: true, desynchronized: true }) || canvas.getContext('2d'); }\n" +
|
||||
"try { return canvas.getContext('2d', { alpha: true }) || canvas.getContext('2d'); }\n" +
|
||||
"catch (_) { return canvas.getContext('2d'); }")
|
||||
private static native CanvasRenderingContext2D create2dContext(HTMLCanvasElement canvas);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ public interface WebGL2 extends JSObject {
|
||||
int SRC_ALPHA = 0x0302;
|
||||
int ONE_MINUS_SRC_ALPHA = 0x0303;
|
||||
int DEPTH_TEST = 0x0B71;
|
||||
int SCISSOR_TEST = 0x0C11;
|
||||
int BLEND = 0x0BE2;
|
||||
int POLYGON_OFFSET_FILL = 0x8037;
|
||||
int FLOAT = 0x1406;
|
||||
@@ -65,12 +66,13 @@ public interface WebGL2 extends JSObject {
|
||||
interface UniformLocation extends JSObject {}
|
||||
|
||||
@JSBody(params = {"canvas"}, script =
|
||||
"return canvas.getContext('webgl2', { alpha: false, antialias: false, preserveDrawingBuffer: false, powerPreference: 'high-performance', desynchronized: true });")
|
||||
"return canvas.getContext('webgl2', { alpha: false, antialias: false, preserveDrawingBuffer: true, powerPreference: 'high-performance' });")
|
||||
static WebGL2 getContext(HTMLCanvasElement canvas) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void viewport(int x, int y, int width, int height);
|
||||
void scissor(int x, int y, int width, int height);
|
||||
void clearColor(float r, float g, float b, float a);
|
||||
void clear(int mask);
|
||||
void enable(int cap);
|
||||
|
||||
@@ -358,6 +358,8 @@ public final class WebHd317Renderer implements HD317Pipeline.HdRendererBackend {
|
||||
int vpY = ClientSettings.isDesktopModern() ? 0 : Math.max(0, canvasH - 4 - height);
|
||||
gl.bindFramebuffer(WebGL2.FRAMEBUFFER, null);
|
||||
gl.viewport(vpX, vpY, width, height);
|
||||
gl.enable(WebGL2.SCISSOR_TEST);
|
||||
gl.scissor(vpX, vpY, width, height);
|
||||
gl.clearColor(fogColor[0], fogColor[1], fogColor[2], 1.0f);
|
||||
gl.clear(WebGL2.COLOR_BUFFER_BIT | WebGL2.DEPTH_BUFFER_BIT);
|
||||
gl.enable(WebGL2.DEPTH_TEST);
|
||||
@@ -466,6 +468,7 @@ public final class WebHd317Renderer implements HD317Pipeline.HdRendererBackend {
|
||||
|
||||
unbindSceneVertexAttribs();
|
||||
}
|
||||
gl.disable(WebGL2.SCISSOR_TEST);
|
||||
|
||||
if (!loggedFirstFrame) {
|
||||
loggedFirstFrame = true;
|
||||
@@ -711,7 +714,14 @@ public final class WebHd317Renderer implements HD317Pipeline.HdRendererBackend {
|
||||
public static boolean ensureOverlayReady() {
|
||||
if (isOverlayReady()) return true;
|
||||
if (instance == null) {
|
||||
new WebHd317Renderer();
|
||||
if (HD317Pipeline.backend instanceof WebHd317Renderer) {
|
||||
instance = (WebHd317Renderer) HD317Pipeline.backend;
|
||||
} else {
|
||||
instance = new WebHd317Renderer();
|
||||
if (HD317Pipeline.backend == null) {
|
||||
HD317Pipeline.backend = instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance.ensureOverlayContext();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user