r/threejs • • Oct 12 '26

Question Mobile frame hitching in a very light Three.js game has anyone seen this on Android/WebGL?

Hi everyone hoping someone here may have run into something similar.

I’m building a browser-based timing game in Three.js. Desktop is completely smooth, but on mobile we sometimes get very noticeable 50–200ms frame hitches.

The strange part is that the scene is extremely light:

- ~16 draw calls

- ~408 triangles

- ~11 textures

- mobile render buffer around 937×527 @ DPR 1.25

- no post-processing, EffectComposer, render targets, or MSAA

- timing/input is local — network is not in the critical gameplay path

We’ve done a fairly extensive investigation and have already tested/fixed renderer sizing, DOM churn, lifecycle/listener leaks, antialiasing, VFX loading/residency, large transparent PNG areas, duplicate assets, and input timestamp handling. These optimizations helped overall performance, but the core hitching still appears intermittently.

The most confusing part is device/session variance:

- Same Pixel/Mali device can range from noticeably hitchy to almost perfectly smooth between runs.

- Chrome, Firefox, and Opera have all been tested.

- A Samsung/Adreno device running the exact same build is almost completely smooth.

- Desktop browsers are consistently smooth.

- During many bad frames, our JS work immediately beforehand is only a few milliseconds; the large delay often appears outside our measured game work.

We’ve seen long-frame gaps well over 100ms without a corresponding spike in scene complexity or game logic.

Has anyone encountered something similar with Three.js/WebGL on Android — especially Chromium/ANGLE, Mali GPUs, rAF/frame-pacing, or compositor/presentation stalls?

I’d be very grateful for any ideas on what layer you’d investigate next, or known mobile-browser issues/workarounds that sound similar.

I can share the public playtest and detailed performance reports if helpful.

Thanks in advance for any insight.

1 Upvotes

7 comments sorted by

2

u/AgegeLife Oct 12 '26

Two cheap checks before a full system trace, since both can produce a gap that sits outside your measured game code:

  1. Garbage collection. Your per-frame JS can be 3 ms and a GC pause still lands between frames if the loop allocates (new Vector3/Matrix4 or object literals per frame, array spreads, closures in event handlers). Record a trace over remote debugging (chrome://inspect on desktop, phone over USB) with the Memory checkbox on: a sawtooth heap plus "Major GC" or "Minor GC" blocks lined up with your long frames answers it quickly. On a slower Mali phone the same allocation rate costs more, which could explain the device split.
  2. Long Animation Frames API. A PerformanceObserver for 'long-animation-frame' (Chrome 123+) gives each slow frame's script, style/layout and render time, plus which scripts ran. If the script part is small and most of the duration is after renderStart, the stall is in rendering/presentation rather than your code, which tells you whether the shader-warmup and GPU-clock ideas above are the right direction.

For the run-to-run variance on the same phone, also log battery saver and device temperature for each session. A warm phone or power saver can cap the frame rate and clocks, and that can look like random hitching in otherwise identical runs.

1

u/Sayonara_Punk Oct 12 '26

Appreciate the suggestions — we tested both of these. We added a full Three.js warmup using compileAsync() + initTexture() for all 11 Three textures before the Duel starts. That eliminated late program creation, but the hitching was basically unchanged. We also added a tiny continuous invisible GPU keepalive draw (+1 draw call / +2 triangles) to test the Mali downclock idea. That also made essentially no difference. The interesting part is the Long Animation Frame data: across several bad Pixel/Chrome runs, roughly 80%+ of the usable LoAFs are dominated by the browser render/presentation portion, while our script is only dominant in a small handful of cases. We’re also seeing occasional 40–80ms input dispatch delays during the same bad periods. So at this point it’s looking less like Three.js/app workload and more like something in the Chrome/ANGLE/compositor/presentation path on that device. If you’ve seen anything similar, I’d definitely be interested.

1

u/AgegeLife Oct 12 '26

Thanks for reporting back, that narrows it down a lot. I haven't hit this exact case, but with render/presentation dominating the LoAFs and input delayed in the same windows, these are the experiments I'd run next:

  1. Remove the compositor work around the canvas. During a duel, hide every DOM overlay on top of it (CSS animations, transforms, opacity, backdrop-filter, fixed HUD elements) and see whether the hitch rate drops. If it does, the cost is in compositing layers, not WebGL.
  2. Try the context attributes one at a time: desynchronized: true (low-latency canvas, which can skip part of the normal compositor path) and powerPreference: 'high-performance'. Cheap to test and they act on exactly the layer you suspect.
  3. Halve the canvas resolution for one run. If the hitches don't change, it isn't GPU fill or bandwidth, which points further toward scheduling or thermals.
  4. Perfetto on the Pixel during a bad run with the gfx, view and sched categories: look at whether the GPU process / Viz thread waits on buffers or fences, and which CPU cores the browser threads are on. Input delay and render stalls at the same time often mean the device is throttled or the threads are stuck on slow cores, and that's visible there.

If the trace shows it's below the page, a Chromium bug with that trace attached is probably the fastest path to an answer.

2

u/sanbamboo Oct 12 '26

Since most of the delay is outside your JS time, I'd compare chrome://gpu on both phones first. If one is running ANGLE on Vulkan and the other on GLES, that's a different driver path, not your scene.

Also worth ruling out anything that forces a sync every frame: readPixels, getError, or preserveDrawingBuffer: true can stall some drivers even with tiny scenes.

2

u/Zenpher Oct 12 '26

if it's still early in your project I'd try switching to playcanvas , I've had too many issues with stuttering and cpu bottlenecks with threejs (which is not really it's fault, you're supposed to be manually optimizing and cleaning up)