GitHub Actions commited on
Commit
1b7cc6e
Β·
1 Parent(s): 43a358a

sync from abhijitramesh/webgpu-bench@4f567a5d06

Browse files
Files changed (1) hide show
  1. js/run/device.js +30 -12
js/run/device.js CHANGED
@@ -227,11 +227,20 @@ async function _computeBudget() {
227
 
228
  const isMobile = isMobileDevice();
229
 
230
- // Run both probes in parallel.
231
- const [heapProbe, gpuProbe] = await Promise.all([
232
- probeHeapBudgetMB(),
233
- probeGpuBudgetMB(),
234
- ]);
 
 
 
 
 
 
 
 
 
235
 
236
  // ── Heap budget ──
237
  let heapBudgetMB;
@@ -255,13 +264,22 @@ async function _computeBudget() {
255
  }
256
 
257
  // ── GPU budget ──
258
- let gpuBudgetMB = gpuProbe.probedMB;
259
- let gpuSource = gpuProbe.probedMB > 0
260
- ? `probe (WebGPU buffers, ${gpuProbe.probedMB} MB allocated)`
261
- : `probe failed: ${gpuProbe.error || 'unknown'}`;
262
- if (isMobile && gpuBudgetMB > MOBILE_GPU_CEILING_MB) {
263
- gpuBudgetMB = MOBILE_GPU_CEILING_MB;
264
- gpuSource += ' β†’ mobile-capped';
 
 
 
 
 
 
 
 
 
265
  }
266
 
267
  return {
 
227
 
228
  const isMobile = isMobileDevice();
229
 
230
+ // The heap probe is always safe β€” it runs inside a dedicated worker so
231
+ // a runaway grow() kills the worker, not the tab.
232
+ //
233
+ // The GPU probe is NOT safe on mobile. It allocates real WebGPU buffers
234
+ // in the GPU process, which is shared with the main tab. On phones,
235
+ // pushing 1–2 GB of GPU buffers triggers OOM behavior in iOS Safari
236
+ // that reaps the tab β€” which then reloads, reprobes, and reaps again,
237
+ // an infinite refresh loop. Skip the probe on mobile and substitute a
238
+ // heuristic based on navigator.deviceMemory; on desktop the GPU process
239
+ // has enough headroom for the probe to be useful.
240
+ const heapProbe = await probeHeapBudgetMB();
241
+ const gpuProbe = isMobile
242
+ ? { probedMB: 0, error: 'skipped on mobile (would OOM the tab)' }
243
+ : await probeGpuBudgetMB();
244
 
245
  // ── Heap budget ──
246
  let heapBudgetMB;
 
264
  }
265
 
266
  // ── GPU budget ──
267
+ let gpuBudgetMB;
268
+ let gpuSource;
269
+ if (isMobile) {
270
+ // Heuristic since the probe would OOM the tab. Quarter of the
271
+ // device's reported RAM, clamped to a sensible range. iPhone WebGPU
272
+ // typically gives a tab 1.5–2 GB of usable GPU memory before things
273
+ // start failing; this estimate undershoots slightly to leave margin.
274
+ const memMB = (memGB || 4) * 1024;
275
+ gpuBudgetMB = Math.max(512, Math.min(memMB * 0.25, MOBILE_GPU_CEILING_MB));
276
+ gpuSource = `mobile heuristic (deviceMemory ${memGB ?? '?'} GB Γ— 0.25, clamped 512 MB–${MOBILE_GPU_CEILING_MB} MB)`;
277
+ } else if (gpuProbe.probedMB > 0) {
278
+ gpuBudgetMB = gpuProbe.probedMB;
279
+ gpuSource = `probe (WebGPU buffers, ${gpuProbe.probedMB} MB allocated)`;
280
+ } else {
281
+ gpuBudgetMB = 0;
282
+ gpuSource = `probe failed: ${gpuProbe.error || 'unknown'}`;
283
  }
284
 
285
  return {