WebGL context lost and stutter in Android WebView for voxel viewer

Hi everyone, I have been working on a Babylon.js project designed to render 3D character and skin previews for mobile users who run Minecraft Java on portable devices through PojavLauncher. Everything runs smoothly in modern desktop browsers, but when I test the canvas embedded inside an Android WebView on mid-range phones, the engine periodically freezes or triggers a WebGL context lost error right after swapping out skin textures.

I already experimented with lowering the hardware scaling level and optimizing my material instances, but the memory spikes still seem to overwhelm the webview process during asset reloads. While reviewing some setup configurations and client performance notes discussed on their website, I noticed other community members recommending strict manual garbage collection for embedded render loops, so I suspect my texture disposal workflow might be missing a step.

Has anyone encountered similar context drops or disposal bottlenecks when rendering voxel meshes inside embedded mobile wrappers? I would really appreciate any guidance on how to properly handle context restoration or stabilize memory consumption without forcing a full page reload.

One thing to check: lowering the hardware scaling value increases rendering resolution in Babylon.js. To reduce GPU load, increase it instead—for example, engine.setHardwareScalingLevel(2) renders at half the canvas’s CSS width and height.

There’s no manual garbage-collection step required. Assigning a new texture to a material does not dispose the previous one, so explicitly call oldTexture.dispose() once nothing else uses it. Also check that rapid skin changes aren’t accumulating overlapping loads or recreating scenes/materials unnecessarily.

Babylon handles WebGL context restoration by default, so leave doNotHandleContextLost unset or false. Recovery still depends on the browser restoring the context; it cannot recover a WebView renderer process that Android has killed.

A minimal reproduction showing the texture-swap/disposal code, along with texture dimensions, Babylon.js/WebView versions, and device details, would help narrow this down. Context loss alone doesn’t prove a texture leak.

Have you tried deferring the removal to the next onAfterRenderObservable that fires once and then is removed?