@aardworx/wombat.rendering 0.19.25 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/core/renderObject.d.ts +9 -0
  2. package/dist/core/renderObject.d.ts.map +1 -1
  3. package/dist/resources/preparedRenderObject.d.ts.map +1 -1
  4. package/dist/resources/preparedRenderObject.js +9 -3
  5. package/dist/resources/preparedRenderObject.js.map +1 -1
  6. package/dist/resources/uniformBuffer.d.ts.map +1 -1
  7. package/dist/resources/uniformBuffer.js +3 -1
  8. package/dist/resources/uniformBuffer.js.map +1 -1
  9. package/dist/runtime/derivedUniforms/codegen.d.ts.map +1 -1
  10. package/dist/runtime/derivedUniforms/codegen.js +34 -13
  11. package/dist/runtime/derivedUniforms/codegen.js.map +1 -1
  12. package/dist/runtime/derivedUniforms/dispatch.d.ts.map +1 -1
  13. package/dist/runtime/derivedUniforms/dispatch.js +6 -0
  14. package/dist/runtime/derivedUniforms/dispatch.js.map +1 -1
  15. package/dist/runtime/derivedUniforms/sceneIntegration.d.ts.map +1 -1
  16. package/dist/runtime/derivedUniforms/sceneIntegration.js +9 -4
  17. package/dist/runtime/derivedUniforms/sceneIntegration.js.map +1 -1
  18. package/dist/runtime/heapAdapter.d.ts.map +1 -1
  19. package/dist/runtime/heapAdapter.js +3 -0
  20. package/dist/runtime/heapAdapter.js.map +1 -1
  21. package/dist/runtime/heapEffect.d.ts +23 -1
  22. package/dist/runtime/heapEffect.d.ts.map +1 -1
  23. package/dist/runtime/heapEffect.js +17 -2
  24. package/dist/runtime/heapEffect.js.map +1 -1
  25. package/dist/runtime/heapEffectIR.d.ts.map +1 -1
  26. package/dist/runtime/heapEffectIR.js +33 -2
  27. package/dist/runtime/heapEffectIR.js.map +1 -1
  28. package/dist/runtime/heapScene.d.ts +9 -0
  29. package/dist/runtime/heapScene.d.ts.map +1 -1
  30. package/dist/runtime/heapScene.js +90 -1
  31. package/dist/runtime/heapScene.js.map +1 -1
  32. package/dist/runtime/heapShaderFamily.d.ts.map +1 -1
  33. package/dist/runtime/heapShaderFamily.js +19 -0
  34. package/dist/runtime/heapShaderFamily.js.map +1 -1
  35. package/dist/runtime/hybridScene.d.ts +6 -0
  36. package/dist/runtime/hybridScene.d.ts.map +1 -1
  37. package/dist/runtime/hybridScene.js +17 -0
  38. package/dist/runtime/hybridScene.js.map +1 -1
  39. package/dist/runtime/renderTask.d.ts +6 -0
  40. package/dist/runtime/renderTask.d.ts.map +1 -1
  41. package/dist/runtime/renderTask.js +3 -0
  42. package/dist/runtime/renderTask.js.map +1 -1
  43. package/dist/runtime/runtime.d.ts +15 -0
  44. package/dist/runtime/runtime.d.ts.map +1 -1
  45. package/dist/runtime/runtime.js +3 -0
  46. package/dist/runtime/runtime.js.map +1 -1
  47. package/dist/runtime/textureAtlas/atlasMipGutterKernel.d.ts +19 -2
  48. package/dist/runtime/textureAtlas/atlasMipGutterKernel.d.ts.map +1 -1
  49. package/dist/runtime/textureAtlas/atlasMipGutterKernel.js +37 -6
  50. package/dist/runtime/textureAtlas/atlasMipGutterKernel.js.map +1 -1
  51. package/dist/runtime/textureAtlas/atlasPool.d.ts +5 -0
  52. package/dist/runtime/textureAtlas/atlasPool.d.ts.map +1 -1
  53. package/dist/runtime/textureAtlas/atlasPool.js +25 -3
  54. package/dist/runtime/textureAtlas/atlasPool.js.map +1 -1
  55. package/dist/window/loop.d.ts.map +1 -1
  56. package/dist/window/loop.js +31 -4
  57. package/dist/window/loop.js.map +1 -1
  58. package/package.json +3 -3
  59. package/src/core/renderObject.ts +9 -0
  60. package/src/resources/preparedRenderObject.ts +7 -3
  61. package/src/resources/uniformBuffer.ts +3 -1
  62. package/src/runtime/derivedUniforms/codegen.ts +34 -13
  63. package/src/runtime/derivedUniforms/dispatch.ts +6 -0
  64. package/src/runtime/derivedUniforms/sceneIntegration.ts +9 -4
  65. package/src/runtime/heapAdapter.ts +3 -0
  66. package/src/runtime/heapEffect.ts +30 -2
  67. package/src/runtime/heapEffectIR.ts +36 -2
  68. package/src/runtime/heapScene.ts +109 -1
  69. package/src/runtime/heapShaderFamily.ts +21 -0
  70. package/src/runtime/hybridScene.ts +23 -0
  71. package/src/runtime/renderTask.ts +9 -0
  72. package/src/runtime/runtime.ts +18 -0
  73. package/src/runtime/textureAtlas/atlasMipGutterKernel.ts +52 -3
  74. package/src/runtime/textureAtlas/atlasPool.ts +28 -2
  75. package/src/window/loop.ts +32 -4
@@ -131,6 +131,8 @@ export function runFrame(
131
131
  let lastTime = performance.now();
132
132
  let rafId = 0;
133
133
  let pending = false;
134
+ let consecutiveErrors = 0;
135
+ const MAX_CONSECUTIVE_ERRORS = 30;
134
136
  const UNCAPPED = isUncapped();
135
137
 
136
138
  // Wrap the frame callback in an AVal so the adaptive system tracks
@@ -143,10 +145,34 @@ export function runFrame(
143
145
  attachment.markFrame();
144
146
  try {
145
147
  frame(token, { frame: frameNo, timestampMs: now, deltaMs: delta });
148
+ consecutiveErrors = 0;
146
149
  } catch (e) {
147
- stopped = true;
148
- console.error("runFrame: error in frame callback", e);
149
- throw e;
150
+ // A throwing frame used to kill the loop for good. That is far too harsh
151
+ // for a transient fault (a resource disposed mid-frame, a one-off device
152
+ // hiccup): the page then looks alive — DOM, input and workers all keep
153
+ // running — while nothing renders again and any animation driven from the
154
+ // frame callback freezes. Retry instead, and only give up if the fault
155
+ // repeats every frame (a genuinely broken scene, which would otherwise
156
+ // spin the error path forever).
157
+ consecutiveErrors++;
158
+ console.error(
159
+ `runFrame: error in frame callback (${consecutiveErrors}/${MAX_CONSECUTIVE_ERRORS})`, e,
160
+ );
161
+ if (consecutiveErrors >= MAX_CONSECUTIVE_ERRORS) {
162
+ stopped = true;
163
+ console.error("runFrame: giving up after repeated frame errors — render loop stopped");
164
+ throw e;
165
+ }
166
+ // Keep the loop breathing: schedule the next frame ourselves, since a
167
+ // frame that died early may not have read the inputs it would be marked
168
+ // by. Swallow the error rather than rethrowing — an exception escaping
169
+ // the aval eval leaves the wrapper's dirty state ambiguous, and we have
170
+ // already reported it.
171
+ queueMicrotask(() => {
172
+ if (stopped || pending) return;
173
+ pending = true;
174
+ rafId = schedule(tick);
175
+ });
150
176
  }
151
177
  frameNo++;
152
178
  return frameNo;
@@ -188,8 +214,10 @@ export function runFrame(
188
214
  // frame.
189
215
  if (opts.pacer !== undefined) {
190
216
  opts.pacer().then(finalizeFrame, (e) => {
191
- stopped = true;
217
+ // A rejected pacer (GPU hiccup) must not brick the loop either — the
218
+ // frame is done as far as we're concerned; carry on.
192
219
  console.error("runFrame: pacer rejected", e);
220
+ finalizeFrame();
193
221
  });
194
222
  } else {
195
223
  finalizeFrame();