@null3d/engine 0.0.0 → 0.1.1
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.
- package/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +25 -10
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +25 -10
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +114 -86
- package/docs/api/assets.md +135 -49
- package/docs/api/cameras.md +45 -12
- package/docs/api/controls.md +88 -62
- package/docs/api/debug.md +116 -41
- package/docs/api/engine.md +117 -35
- package/docs/api/feature-draws.md +23 -17
- package/docs/api/feature-effects.md +11 -11
- package/docs/api/feature-instances.md +70 -19
- package/docs/api/features.md +77 -47
- package/docs/api/geometry.md +132 -82
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +175 -22
- package/docs/api/input.md +24 -18
- package/docs/api/lights.md +78 -51
- package/docs/api/lines.md +41 -33
- package/docs/api/materials.md +248 -121
- package/docs/api/math.md +12 -13
- package/docs/api/objects.md +47 -22
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +33 -20
- package/docs/api/points.md +19 -31
- package/docs/api/post.md +75 -42
- package/docs/api/quality.md +42 -17
- package/docs/api/raycast.md +65 -51
- package/docs/api/reference/animation.md +10 -11
- package/docs/api/reference/assets.md +25 -22
- package/docs/api/reference/cameras.md +8 -4
- package/docs/api/reference/controls.md +134 -25
- package/docs/api/reference/debug.md +81 -14
- package/docs/api/reference/engine.md +58 -17
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +287 -97
- package/docs/api/reference/grass.md +63 -3
- package/docs/api/reference/impostors.md +208 -13
- package/docs/api/reference/input.md +4 -5
- package/docs/api/reference/lights.md +13 -12
- package/docs/api/reference/lines.md +10 -11
- package/docs/api/reference/materials.md +54 -53
- package/docs/api/reference/math.md +35 -24
- package/docs/api/reference/objects.md +11 -12
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +6 -7
- package/docs/api/reference/post.md +21 -20
- package/docs/api/reference/quality.md +8 -5
- package/docs/api/reference/raycast.md +7 -8
- package/docs/api/reference/render.md +5 -4
- package/docs/api/reference/scene.md +52 -30
- package/docs/api/reference/sketch.md +15 -11
- package/docs/api/reference/sound.md +234 -0
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +7 -8
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +27 -5
- package/docs/api/reference/textures.md +5 -6
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +12 -9
- package/docs/api/reference/vertex-draws.md +5 -6
- package/docs/api/reference/water.md +153 -9
- package/docs/api/reference/wind.md +17 -4
- package/docs/api/render.md +73 -29
- package/docs/api/scene.md +164 -60
- package/docs/api/sketch.md +102 -15
- package/docs/api/sound.md +205 -0
- package/docs/api/splats.md +46 -12
- package/docs/api/sprites.md +10 -24
- package/docs/api/tasks.md +33 -24
- package/docs/api/terrain.md +42 -22
- package/docs/api/textures.md +68 -19
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +19 -23
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +262 -35
- package/docs/api/wind.md +63 -17
- package/docs/cli/null3d.md +177 -27
- package/docs/concepts/architecture.md +73 -27
- package/docs/concepts/assets.md +57 -33
- package/docs/concepts/backends.md +69 -27
- package/docs/concepts/color-management.md +54 -36
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +74 -25
- package/docs/concepts/large-worlds.md +18 -8
- package/docs/concepts/lighting.md +155 -87
- package/docs/concepts/lod.md +126 -44
- package/docs/concepts/materials.md +58 -27
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +84 -43
- package/docs/concepts/quality-preset-tables.md +56 -52
- package/docs/concepts/quality-presets.md +164 -52
- package/docs/concepts/render-graph.md +69 -29
- package/docs/concepts/render-layers.md +11 -21
- package/docs/concepts/shadows.md +105 -52
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +164 -120
- package/docs/data/threejs-mapping.json +362 -367
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +14 -6
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +40 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +14 -6
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +54 -30
- package/docs/getting-started/cdn.md +32 -10
- package/docs/getting-started/first-scene.md +21 -13
- package/docs/getting-started/hosting.md +152 -63
- package/docs/getting-started/install.md +44 -28
- package/docs/getting-started/network-use.md +33 -15
- package/docs/getting-started/project-structure.md +33 -12
- package/docs/getting-started/third-party-notices.md +12 -14
- package/docs/guides/accessibility.md +5 -5
- package/docs/guides/add-ons.md +86 -15
- package/docs/guides/agents.md +16 -9
- package/docs/guides/assets-pipeline.md +259 -82
- package/docs/guides/audio.md +115 -128
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +38 -32
- package/docs/guides/content-pages.md +63 -35
- package/docs/guides/custom-passes.md +65 -22
- package/docs/guides/custom-shaders.md +59 -39
- package/docs/guides/debugging.md +74 -10
- package/docs/guides/deploying.md +85 -6
- package/docs/guides/deterministic-simulation.md +24 -17
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +132 -47
- package/docs/guides/multiple-views.md +63 -13
- package/docs/guides/performance.md +192 -38
- package/docs/guides/phones.md +78 -15
- package/docs/guides/physics.md +7 -11
- package/docs/guides/screens.md +47 -33
- package/docs/guides/start-time.md +363 -0
- package/docs/guides/testing.md +152 -95
- package/docs/guides/ui-overlays.md +19 -14
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +18 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -209
- package/docs/porting/react-three-fiber.md +225 -6
- package/docs/porting/threejs-loop-and-threads.md +217 -7
- package/docs/porting/threejs-mapping.md +1249 -233
- package/docs/porting/threejs-materials.md +218 -6
- package/docs/porting/threejs-overview.md +240 -7
- package/docs/porting/threejs-postprocessing.md +4 -8
- package/docs/porting/threejs-shaders.md +301 -6
- package/docs/porting/threejs-unsupported.md +83 -7
- package/docs/porting/verification.md +178 -6
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +72 -45
- package/docs/shaders/surface-functions.md +59 -23
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +11 -9
- package/lib/debug/draw.d.ts +11 -2
- package/lib/debug/draw.js +57 -6
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +22 -7
- package/lib/debug/stats-panel.js +80 -13
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +117 -105
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +20 -19
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +5 -2
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +28 -14
- package/lib/index.d.ts +7 -5
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +8 -8
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +117 -31
- package/lib/page/engine.js +438 -99
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +26 -14
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +38 -6
- package/lib/page/switches.js +29 -5
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +3 -3
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +35 -4
- package/lib/scene/frame-cameras.js +86 -10
- package/lib/scene/gltf.d.ts +33 -3
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +121 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +39 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +238 -261
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +167 -120
- package/lib/scene/scene.js +243 -103
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +11 -7
- package/lib/scene/time-of-day.js +11 -8
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +51 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +80 -9
- package/lib/sketch/runner.js +390 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +71 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +29 -5
- package/lib/workers/sketch-worker.js +108 -16
- package/package.json +2 -2
package/lib/page/engine.js
CHANGED
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
// and the quality preset, starts the workers, and hands the canvas to the thread that draws. The
|
|
3
3
|
// page loads the renderer only when it draws itself, and the sketch runner and the scene API only
|
|
4
4
|
// when it runs the sketch itself: in the single-threaded build, and with sketchThread: 'main'.
|
|
5
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
6
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
7
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
8
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return path;
|
|
12
|
+
};
|
|
5
13
|
import { DEV } from '../errors/checks.js';
|
|
6
14
|
import { EngineError, errorFixesReady, errorOfMessage } from '../errors/engine-error.js';
|
|
7
15
|
import { messageOf } from '../errors/message.js';
|
|
8
16
|
import { FORMAT_CANVAS, PERMUTATION_HALF } from '../generated/gpu.js';
|
|
9
17
|
import { SHADER_FEATURES } from '../generated/shader-features.js';
|
|
10
|
-
import { recordPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
11
|
-
import { maxTargetFps } from '../quality/check.js';
|
|
12
|
-
import { choosePreset, crashTier, deviceKind, gpuOcclusionChoice, memoryPreset, textureMemoryCap, withinTier, } from '../quality/chooser.js';
|
|
18
|
+
import { recordPermutations, reportPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
19
|
+
import { maxTargetFps, } from '../quality/check.js';
|
|
20
|
+
import { choosePreset, crashLowest, crashTier, deviceKind, gpuOcclusionChoice, memoryPreset, textureMemoryCap, withinTier, } from '../quality/chooser.js';
|
|
13
21
|
import { readDeviceHints } from '../quality/device-hints.js';
|
|
14
|
-
import { capTextureMemory, checkedSettings, checkSettings, presetOption, presetValue, targetFpsOption, } from '../quality/presets.js';
|
|
15
|
-
import { loadDrawModule,
|
|
22
|
+
import { capTextureMemory, checkedSettings, checkSettings, lowestTierSettings, presetCheckOption, presetOption, presetValue, targetFpsOption, } from '../quality/presets.js';
|
|
23
|
+
import { loadDrawModule, preloadDrawing } from '../render/load-draw.js';
|
|
16
24
|
import { awaitLater } from '../shared/await-later.js';
|
|
17
25
|
import { controlViews, createControlBuffer, Slot } from '../shared/control.js';
|
|
18
26
|
import { loadGlue, startCore } from '../shared/core.js';
|
|
@@ -24,19 +32,22 @@ import { KEY_CODES } from '../shared/key-codes.js';
|
|
|
24
32
|
import { memoryBytes } from '../shared/memory-views.js';
|
|
25
33
|
import { createMetricsBuffer, MetricsReader, threadRoles } from '../shared/metrics.js';
|
|
26
34
|
import { addMeasurementRelease } from '../shared/page-measurement.js';
|
|
35
|
+
import { PERMUTATION_WORD_EVENT } from '../shared/permutation-words.js';
|
|
36
|
+
import { sketchDataText } from '../shared/sketch-data.js';
|
|
27
37
|
import { clearJobTasks, jobAsker, setJobTasks } from '../shared/task-host.js';
|
|
28
|
-
import { onAddonChecked } from '../shared/version.js';
|
|
38
|
+
import { hearAddonsEarly, onAddonChecked } from '../shared/version.js';
|
|
29
39
|
import { VIDEO_FOLLOW } from '../shared/videos.js';
|
|
30
40
|
import { notifySlot, setWakeByMessage } from '../shared/wake.js';
|
|
31
41
|
import { WGSL_UPDATE_EVENT } from '../shared/wgsl-updates.js';
|
|
32
|
-
import { spawnWorker, startedWorkerScript, watchWorkerError } from '../shared/worker-start.js';
|
|
42
|
+
import { spawnWorker, startedWorkerScript, watchWorkerError, workerScriptOf, } from '../shared/worker-start.js';
|
|
33
43
|
import { loadSketch } from '../sketch/define-sketch.js';
|
|
34
44
|
import { abortable } from './abortable.js';
|
|
35
45
|
import { checkBrowser } from './browser-check.js';
|
|
36
46
|
import { watchCanvas } from './canvas-watch.js';
|
|
37
47
|
import { forgetWorkerProbe, probeCapabilities, } from './capabilities.js';
|
|
38
|
-
import { CheckStore, checkConditions } from './check-store.js';
|
|
48
|
+
import { CheckStore, checkConditions, checkEnded, checkedPreset } from './check-store.js';
|
|
39
49
|
import { watchDisplay } from './display.js';
|
|
50
|
+
import { FirstFrame } from './first-frame.js';
|
|
40
51
|
import { holdFailure, holdSeconds, publishHold, holdScript as readHoldScript, } from './hold.js';
|
|
41
52
|
import { captureInput } from './input.js';
|
|
42
53
|
import { lostIsolationWarning, pageIsolation } from './isolation-check.js';
|
|
@@ -47,6 +58,7 @@ import { MainThreadWatch } from './main-thread.js';
|
|
|
47
58
|
import { keepMemory, releaseMemories } from './memory-pool.js';
|
|
48
59
|
import { canvasHold, Holder, parkWorker, takeParkedWorker, takeWhenFree, } from './ownership.js';
|
|
49
60
|
import { PermutationRecording } from './permutation-recording.js';
|
|
61
|
+
import { PipelineStore, pipelineConditions } from './pipeline-store.js';
|
|
50
62
|
import { requestPointerLock } from './pointer-lock.js';
|
|
51
63
|
import { watchPreferences } from './preferences.js';
|
|
52
64
|
import { NO_HISTORY, StartMarker } from './start-marker.js';
|
|
@@ -65,6 +77,8 @@ let warnedFallback = false;
|
|
|
65
77
|
let warnedIsolation = false;
|
|
66
78
|
/** The global where the `?bench` switch publishes the running engine. */
|
|
67
79
|
const BENCH_GLOBAL = '__null3dEngine';
|
|
80
|
+
/** The global where a development build publishes its inspection bridge, for the MCP server. */
|
|
81
|
+
const INSPECTOR_GLOBAL = '__null3dInspector';
|
|
68
82
|
/** The GPU the engine asks for on a device with two: the faster one. */
|
|
69
83
|
const DEFAULT_POWER_PREFERENCE = 'high-performance';
|
|
70
84
|
/** How often the page reads the frame records while it measures. */
|
|
@@ -89,6 +103,19 @@ const MAX_EARLY_MESSAGES = 256;
|
|
|
89
103
|
* the page to wait with no end.
|
|
90
104
|
*/
|
|
91
105
|
export const WORKER_REPLY_LIMIT_MS = 600_000;
|
|
106
|
+
/**
|
|
107
|
+
* How long an inspection call waits for the sketch worker's answer. A call runs between frames, but
|
|
108
|
+
* a quality change waits for the pipelines that it needs, so this is longer than a frame and far
|
|
109
|
+
* shorter than the limit that a start or a capture gets.
|
|
110
|
+
*/
|
|
111
|
+
const INSPECT_REPLY_LIMIT_MS = 30_000;
|
|
112
|
+
/**
|
|
113
|
+
* How long a copy of a worker whose script did not load may take to report its first reply. A
|
|
114
|
+
* script that loads reports in about a second on the slowest machines that run the tests, so a
|
|
115
|
+
* copy that has sent nothing by this time never ran: the page fails the start with E1405 rather
|
|
116
|
+
* than waiting for a worker that may never speak.
|
|
117
|
+
*/
|
|
118
|
+
export const RETRY_REPLY_MS = 10_000;
|
|
92
119
|
/** Picks the GPU tier from feature tests, never from browser or GPU names. */
|
|
93
120
|
export function chooseTier(report, wanted, inWorker) {
|
|
94
121
|
const worker = 'failure' in report.worker ? undefined : report.worker;
|
|
@@ -147,13 +174,19 @@ function loadFrameStats() {
|
|
|
147
174
|
return import('./frame-stats.js');
|
|
148
175
|
}
|
|
149
176
|
/**
|
|
150
|
-
* The error of a GPU that ran out of memory (E1304)
|
|
151
|
-
* as "the render
|
|
177
|
+
* The error of a GPU that ran out of memory (E1304), rejected a command (E1305), or whose driver
|
|
178
|
+
* could not build a pipeline of the scene's objects (E1307), on `thread`, such as "the render
|
|
179
|
+
* worker". `message` names the pipeline for E1307.
|
|
152
180
|
*/
|
|
153
|
-
export function gpuFailure(thread,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
181
|
+
export function gpuFailure(thread, kind, message) {
|
|
182
|
+
switch (kind) {
|
|
183
|
+
case 'memory':
|
|
184
|
+
return new EngineError('E1304', `${thread}'s GPU ran out of memory: ${message}.`);
|
|
185
|
+
case 'rejected':
|
|
186
|
+
return new EngineError('E1305', `${thread}'s GPU rejected a command: ${message}.`);
|
|
187
|
+
case 'pipeline':
|
|
188
|
+
return new EngineError('E1307', `${thread}'s GPU driver could not build the pipeline of ${message}.`);
|
|
189
|
+
}
|
|
157
190
|
}
|
|
158
191
|
/**
|
|
159
192
|
* A worker whose replies are routed: events to the page's handlers, answers to the oldest request.
|
|
@@ -165,6 +198,12 @@ export class EngineWorker {
|
|
|
165
198
|
script;
|
|
166
199
|
restart;
|
|
167
200
|
waiting = [];
|
|
201
|
+
/**
|
|
202
|
+
* The inspection calls that wait for their answers, by their id. A production build never makes
|
|
203
|
+
* one, so the map is made at the first call.
|
|
204
|
+
*/
|
|
205
|
+
inspectWaiters;
|
|
206
|
+
nextInspect = 1;
|
|
168
207
|
readyPromise;
|
|
169
208
|
stoppedPromise;
|
|
170
209
|
worker;
|
|
@@ -178,6 +217,8 @@ export class EngineWorker {
|
|
|
178
217
|
scriptLoaded = false;
|
|
179
218
|
/** True once the page replaced a worker whose script did not load. */
|
|
180
219
|
retried = false;
|
|
220
|
+
/** Clears the wait for the replacement worker's first reply, or undefined once it has one. */
|
|
221
|
+
retryTimer;
|
|
181
222
|
/**
|
|
182
223
|
* The messages that the page sent before the worker reported that its script loaded. A worker
|
|
183
224
|
* that has not run its script cannot take them, so they wait here: a copy that replaces a
|
|
@@ -228,6 +269,9 @@ export class EngineWorker {
|
|
|
228
269
|
};
|
|
229
270
|
const listen = (worker) => {
|
|
230
271
|
worker.onmessage = (event) => {
|
|
272
|
+
// A worker that answers at all has run its script: the replacement no longer needs
|
|
273
|
+
// its error's wait, and its own error listener names whatever fails next.
|
|
274
|
+
this.heardReply();
|
|
231
275
|
const reply = event.data;
|
|
232
276
|
switch (reply.type) {
|
|
233
277
|
case 'recorded':
|
|
@@ -235,6 +279,10 @@ export class EngineWorker {
|
|
|
235
279
|
// frame has built the scene's pipelines.
|
|
236
280
|
this.recording?.answered(reply.role, reply.permutations);
|
|
237
281
|
return;
|
|
282
|
+
case 'permutation':
|
|
283
|
+
if (DEV)
|
|
284
|
+
announcePermutationWord(reply.word);
|
|
285
|
+
return;
|
|
238
286
|
case 'sketch-message':
|
|
239
287
|
events.sketchMessage(reply.name, reply.data);
|
|
240
288
|
return;
|
|
@@ -262,12 +310,15 @@ export class EngineWorker {
|
|
|
262
310
|
case 'recording':
|
|
263
311
|
events.recording?.(reply.bytes);
|
|
264
312
|
return;
|
|
313
|
+
case 'inspect-reply':
|
|
314
|
+
this.answerInspect(reply);
|
|
315
|
+
return;
|
|
265
316
|
case 'lost':
|
|
266
317
|
forgetWorkerProbe();
|
|
267
318
|
events.failure(new EngineError('E1302', `the ${reply.role} worker lost its GPU: ${reply.reason}.`));
|
|
268
319
|
return;
|
|
269
320
|
case 'gpu-error':
|
|
270
|
-
events.failure(gpuFailure(`the ${reply.role} worker`, reply.
|
|
321
|
+
events.failure(gpuFailure(`the ${reply.role} worker`, reply.kind, reply.message), false);
|
|
271
322
|
return;
|
|
272
323
|
case 'fault':
|
|
273
324
|
// A job worker that failed has left the job system, so a stop need not wait for it.
|
|
@@ -275,6 +326,9 @@ export class EngineWorker {
|
|
|
275
326
|
markStopped();
|
|
276
327
|
failed(reply.message);
|
|
277
328
|
return;
|
|
329
|
+
case 'pipeline-list':
|
|
330
|
+
events.pipelineList?.(reply.list);
|
|
331
|
+
return;
|
|
278
332
|
case 'progress':
|
|
279
333
|
// The first step says that the worker's script and the files that it imports
|
|
280
334
|
// ran, so the worker can now take the messages held for it.
|
|
@@ -305,6 +359,7 @@ export class EngineWorker {
|
|
|
305
359
|
};
|
|
306
360
|
this.unwatch?.();
|
|
307
361
|
this.unwatch = watchWorkerError(worker, (message) => {
|
|
362
|
+
this.heardReply();
|
|
308
363
|
// A worker whose script, or a file that the script imports, did not load fails before
|
|
309
364
|
// it reports its first step. That fault comes and goes, so the worker gets one more
|
|
310
365
|
// copy before the page reports it, whatever the browser's message says. A failure
|
|
@@ -312,12 +367,22 @@ export class EngineWorker {
|
|
|
312
367
|
// the copy the same way, so it is reported at once.
|
|
313
368
|
if (!this.scriptLoaded && this.restart && !this.retried && !errorOfMessage(message)) {
|
|
314
369
|
this.retried = true;
|
|
315
|
-
worker.
|
|
370
|
+
// The copy starts while the failed worker still runs. A browser can keep a
|
|
371
|
+
// stopped module worker's failed script load in its cache, and a copy started
|
|
372
|
+
// after that stop then waits for a script that never arrives.
|
|
316
373
|
try {
|
|
317
374
|
const copy = this.restart();
|
|
318
375
|
this.worker = copy;
|
|
319
376
|
listen(copy);
|
|
377
|
+
// A copy that never speaks fails the start with E1405, rather than leaving
|
|
378
|
+
// the page to wait for a worker that may never answer.
|
|
379
|
+
this.retryTimer = setTimeout(() => {
|
|
380
|
+
this.retryTimer = undefined;
|
|
381
|
+
failed(this.stalledFailure());
|
|
382
|
+
this.answerStop?.();
|
|
383
|
+
}, RETRY_REPLY_MS);
|
|
320
384
|
events.workerRestart?.(this.role, this.script === undefined ? '' : String(this.script));
|
|
385
|
+
worker.terminate();
|
|
321
386
|
return;
|
|
322
387
|
}
|
|
323
388
|
catch {
|
|
@@ -347,11 +412,31 @@ export class EngineWorker {
|
|
|
347
412
|
: 'its script, or a file that it imports, did not load';
|
|
348
413
|
return this.retried ? `${at}, and a second copy failed too` : at;
|
|
349
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* What the page reports when the copy that replaced a worker whose script did not load has sent
|
|
417
|
+
* nothing within the wait. The first failure named the script; the copy's silence names it too,
|
|
418
|
+
* so a wrong path stays visible and a stall is not read as a wrong path.
|
|
419
|
+
*/
|
|
420
|
+
stalledFailure() {
|
|
421
|
+
const script = this.script === undefined ? '' : String(this.script);
|
|
422
|
+
const at = script
|
|
423
|
+
? `its script at ${script}, or a file that it imports, did not load`
|
|
424
|
+
: 'its script, or a file that it imports, did not load';
|
|
425
|
+
return `${at}, and a second copy sent nothing within ${RETRY_REPLY_MS / 1000} s`;
|
|
426
|
+
}
|
|
427
|
+
/** Ends the wait for a replacement worker's first reply, once one arrives or the worker fails. */
|
|
428
|
+
heardReply() {
|
|
429
|
+
if (this.retryTimer === undefined)
|
|
430
|
+
return;
|
|
431
|
+
clearTimeout(this.retryTimer);
|
|
432
|
+
this.retryTimer = undefined;
|
|
433
|
+
}
|
|
350
434
|
/**
|
|
351
435
|
* Drops the handlers that reach this engine, so a worker that the page keeps, such as a drawing
|
|
352
436
|
* worker parked with its canvas, holds none of the engine or its shared memory alive.
|
|
353
437
|
*/
|
|
354
438
|
detach() {
|
|
439
|
+
this.heardReply();
|
|
355
440
|
this.unwatch?.();
|
|
356
441
|
this.unwatch = undefined;
|
|
357
442
|
this.worker.onmessage = null;
|
|
@@ -417,9 +502,49 @@ export class EngineWorker {
|
|
|
417
502
|
}
|
|
418
503
|
/** Stops the worker, and fails each request that still waits for its answer. */
|
|
419
504
|
terminate() {
|
|
505
|
+
this.heardReply();
|
|
420
506
|
this.worker.terminate();
|
|
421
507
|
for (const pending of this.waiting.splice(0))
|
|
422
508
|
pending.reject(new Error('the engine stopped'));
|
|
509
|
+
const waiters = this.inspectWaiters;
|
|
510
|
+
if (waiters !== undefined) {
|
|
511
|
+
for (const waiter of waiters.values()) {
|
|
512
|
+
clearTimeout(waiter.timer);
|
|
513
|
+
waiter.reject(new Error('the engine stopped'));
|
|
514
|
+
}
|
|
515
|
+
waiters.clear();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Runs a development build's inspection call in this worker, and waits for its answer. The
|
|
520
|
+
* worker answers with the value of the call, or why it failed.
|
|
521
|
+
*/
|
|
522
|
+
inspect(call, args) {
|
|
523
|
+
if (this.inspectWaiters === undefined)
|
|
524
|
+
this.inspectWaiters = new Map();
|
|
525
|
+
const waiters = this.inspectWaiters;
|
|
526
|
+
return new Promise((resolve, reject) => {
|
|
527
|
+
const id = this.nextInspect++;
|
|
528
|
+
const timer = setTimeout(() => {
|
|
529
|
+
waiters.delete(id);
|
|
530
|
+
reject(new Error(`the ${this.role} worker did not answer the ${call} inspection within ${INSPECT_REPLY_LIMIT_MS / 1000} s`));
|
|
531
|
+
}, INSPECT_REPLY_LIMIT_MS);
|
|
532
|
+
waiters.set(id, { resolve, reject, timer });
|
|
533
|
+
this.send({ type: 'inspect', id, call, args });
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
/** Gives an inspection call its answer. */
|
|
537
|
+
answerInspect(reply) {
|
|
538
|
+
const waiters = this.inspectWaiters;
|
|
539
|
+
const waiter = waiters?.get(reply.id);
|
|
540
|
+
if (waiter === undefined)
|
|
541
|
+
return;
|
|
542
|
+
waiters?.delete(reply.id);
|
|
543
|
+
clearTimeout(waiter.timer);
|
|
544
|
+
if (reply.ok)
|
|
545
|
+
waiter.resolve(reply.result);
|
|
546
|
+
else
|
|
547
|
+
waiter.reject(new Error(reply.error ?? 'the inspection call failed'));
|
|
423
548
|
}
|
|
424
549
|
/**
|
|
425
550
|
* Sends a request and waits for the worker's answer, which ends with a failure once the answer
|
|
@@ -565,12 +690,9 @@ function allWorkers(workers) {
|
|
|
565
690
|
function startJobWorker(index, slots, events, started) {
|
|
566
691
|
const failed = (error) => {
|
|
567
692
|
if (Atomics.load(slots, Slot.Running) !== 0)
|
|
568
|
-
events.failure(error instanceof EngineError ? error : startError(`job ${index}`, messageOf(error)), false);
|
|
693
|
+
events.failure(error instanceof EngineError ? error : startError(`job ${index}`, messageOf(error)), false, false);
|
|
569
694
|
};
|
|
570
|
-
const start = () =>
|
|
571
|
-
type: 'module',
|
|
572
|
-
name: `null3d-job-${index}`,
|
|
573
|
-
});
|
|
695
|
+
const start = () => newJobWorker(index);
|
|
574
696
|
try {
|
|
575
697
|
const first = startEngineWorker(start);
|
|
576
698
|
const job = new EngineWorker(first.worker, `job ${index}`, first.script, events, () => startEngineWorker(start).worker);
|
|
@@ -582,6 +704,13 @@ function startJobWorker(index, slots, events, started) {
|
|
|
582
704
|
return undefined;
|
|
583
705
|
}
|
|
584
706
|
}
|
|
707
|
+
/** Constructs job worker `index`, in the form that bundlers read. */
|
|
708
|
+
function newJobWorker(index) {
|
|
709
|
+
return new Worker(new URL('../workers/job-worker.js', import.meta.url), {
|
|
710
|
+
type: 'module',
|
|
711
|
+
name: `null3d-job-${index}`,
|
|
712
|
+
});
|
|
713
|
+
}
|
|
585
714
|
/**
|
|
586
715
|
* Starts an engine worker from a start function, with the engine's own error codes for a failure
|
|
587
716
|
* of a worker's bootstrap from another origin.
|
|
@@ -743,6 +872,7 @@ export async function createEngine(options) {
|
|
|
743
872
|
};
|
|
744
873
|
try {
|
|
745
874
|
checkPreload(options.preload);
|
|
875
|
+
const sketchData = sketchDataText(options.sketchData);
|
|
746
876
|
const hold = holdSeconds(options.hold, switches.hold);
|
|
747
877
|
// A test tool may set a timed script before the page loads. Only hold mode performs it, so a
|
|
748
878
|
// live engine ignores one left on the page.
|
|
@@ -758,7 +888,7 @@ export async function createEngine(options) {
|
|
|
758
888
|
}, () => new EngineError('E1419', 'createEngine() got a canvas that another engine draws on, which has not stopped.'));
|
|
759
889
|
if (canvas.dead)
|
|
760
890
|
throw new EngineError('E1419', `createEngine() got a canvas that no engine can draw on again: ${canvas.dead}.`);
|
|
761
|
-
return await startEngine(options, switches, { hold, holdScript, replay: switches.replay, record: switches.record }, place, canvas, holder, release);
|
|
891
|
+
return await startEngine(options, switches, { hold, holdScript, replay: switches.replay, record: switches.record, sketchData }, place, canvas, holder, release);
|
|
762
892
|
}
|
|
763
893
|
catch (error) {
|
|
764
894
|
release();
|
|
@@ -791,6 +921,10 @@ function placement(options, switches) {
|
|
|
791
921
|
const main = !threaded || (switches.sketchThread ?? options.sketchThread) === 'main';
|
|
792
922
|
return { threaded, sketchThread: main ? 'main' : 'worker' };
|
|
793
923
|
}
|
|
924
|
+
/** Fires the event that hands a permutation word that the page draws with to the dev server. */
|
|
925
|
+
function announcePermutationWord(word) {
|
|
926
|
+
globalThis.dispatchEvent?.(new CustomEvent(PERMUTATION_WORD_EVENT, { detail: word }));
|
|
927
|
+
}
|
|
794
928
|
/**
|
|
795
929
|
* Starts the engine with the page's switches. With a hold time or a replay, it resolves once the
|
|
796
930
|
* last frame is read back, and publishes it.
|
|
@@ -819,6 +953,10 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
819
953
|
const replay = modes.replay === undefined ? undefined : await readReplay(modes.replay, sketchUrl);
|
|
820
954
|
// A replay records nothing of its own: it runs a file that already holds the frames and input.
|
|
821
955
|
const record = modes.record && replay === undefined;
|
|
956
|
+
// A live start loads the sketch's module while the core downloads, so the module's imports and
|
|
957
|
+
// its top-level code run meanwhile. Hold mode, a replay and a recording load it once the runner
|
|
958
|
+
// has seeded the thread's random numbers, so that code draws the same numbers on every run.
|
|
959
|
+
const moduleFirst = hold === undefined && replay === undefined && !record;
|
|
822
960
|
// The quality preset follows the device hints and the crash marker, which the page has at once,
|
|
823
961
|
// so its memory maximum is known before the core loads. Hold mode and the ?preset= switch fix
|
|
824
962
|
// the preset for tests, so they neither read nor write the marker.
|
|
@@ -830,6 +968,8 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
830
968
|
// The highest frame rate that the preset check, the governor and the stats overlay aim for.
|
|
831
969
|
const optionTarget = targetFpsOption(options.targetFps);
|
|
832
970
|
const maxTarget = maxTargetFps(switches.targetFps ?? optionTarget, switches.fps);
|
|
971
|
+
const optionCheck = presetCheckOption(options.presetCheck);
|
|
972
|
+
const checkTiming = switches.presetCheck ?? optionCheck ?? 'during-play';
|
|
833
973
|
const pageSettings = {
|
|
834
974
|
maxPixelRatio: options.maxPixelRatio,
|
|
835
975
|
antialias: options.antialias,
|
|
@@ -877,19 +1017,16 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
877
1017
|
}));
|
|
878
1018
|
// A page that runs the sketch itself needs the core's loader, the sketch runner and the sketch
|
|
879
1019
|
// module right after the core, so they download while the core does: each later start delays the
|
|
880
|
-
// first frame by a round trip on a slow network.
|
|
881
|
-
// the module arrives.
|
|
882
|
-
// numbers, so that code draws the same numbers on every run.
|
|
1020
|
+
// first frame by a round trip on a slow network. A live sketch module's top-level code then runs
|
|
1021
|
+
// when the module arrives.
|
|
883
1022
|
if (sketchOnPage)
|
|
884
1023
|
void awaitLater(loadGlue(build));
|
|
885
1024
|
const runnerModule = sketchOnPage ? loadRunnerModule() : undefined;
|
|
886
1025
|
// A development build with input off hears each add-on that the sketch's module loads, such as
|
|
887
1026
|
// @null3d/controls, from before the load begins, and hands them to the runner once it exists.
|
|
888
|
-
|
|
889
|
-
if (
|
|
890
|
-
|
|
891
|
-
earlyAddons = heard;
|
|
892
|
-
stopEarlyAddons = onAddonChecked((name) => heard.push(name));
|
|
1027
|
+
const earlyAddons = DEV && sketchOnPage && moduleFirst && options.input === false ? hearAddonsEarly() : undefined;
|
|
1028
|
+
if (earlyAddons) {
|
|
1029
|
+
stopEarlyAddons = earlyAddons.stop;
|
|
893
1030
|
// The start runs on with no wait to the try below, whose failure stops the engine and this
|
|
894
1031
|
// hearing with it. A start that throws before that try ends the hearing here.
|
|
895
1032
|
queueMicrotask(() => {
|
|
@@ -897,7 +1034,12 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
897
1034
|
stopEarlyAddons?.();
|
|
898
1035
|
});
|
|
899
1036
|
}
|
|
900
|
-
const sketchModule = sketchOnPage &&
|
|
1037
|
+
const sketchModule = sketchOnPage && moduleFirst ? awaitLater(loadSketch(sketchUrl)) : undefined;
|
|
1038
|
+
// The files that a live sketch lists start downloading once its module and the runner's code
|
|
1039
|
+
// have loaded, unless the runner's setup begins them first.
|
|
1040
|
+
const listed = {};
|
|
1041
|
+
if (sketchModule && runnerModule)
|
|
1042
|
+
Promise.all([sketchModule, runnerModule]).then(([sketch, runner]) => runner.startListedFiles(listed, sketch, pageUrl ?? sketchUrl), () => { });
|
|
901
1043
|
const powerPreference = options.powerPreference ?? DEFAULT_POWER_PREFERENCE;
|
|
902
1044
|
const messageHandlers = new Set();
|
|
903
1045
|
if (options.onSketchMessage)
|
|
@@ -929,7 +1071,22 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
929
1071
|
handler(name, data);
|
|
930
1072
|
};
|
|
931
1073
|
const failureHandlers = new Set();
|
|
1074
|
+
/** Ends hold mode's read-back of its frame, while it reads the frame back. */
|
|
1075
|
+
let endHold;
|
|
932
1076
|
const stopHandlers = new Set();
|
|
1077
|
+
/**
|
|
1078
|
+
* Resolves `engine.presetChecked`: once the check ends, at once where none runs, and once the
|
|
1079
|
+
* engine draws no new frames, which ends a check that measures them.
|
|
1080
|
+
*/
|
|
1081
|
+
let endCheck = () => { };
|
|
1082
|
+
const presetChecked = new Promise((resolve) => {
|
|
1083
|
+
endCheck = resolve;
|
|
1084
|
+
});
|
|
1085
|
+
const firstFrame = new FirstFrame();
|
|
1086
|
+
/** The metrics' header, where the thread that draws writes when the GPU finished the first frame. */
|
|
1087
|
+
let header;
|
|
1088
|
+
/** True once the GPU has finished the first frame. */
|
|
1089
|
+
const firstFrameDone = () => (header?.firstFrameDoneTime ?? 0) > 0;
|
|
933
1090
|
/** True once the engine draws no new frames, which each stop handler hears once. */
|
|
934
1091
|
let drawingEnded = false;
|
|
935
1092
|
/** Runs a stop handler. One that throws is the page's error, which the console shows. */
|
|
@@ -941,10 +1098,16 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
941
1098
|
console.error(error);
|
|
942
1099
|
}
|
|
943
1100
|
};
|
|
944
|
-
|
|
1101
|
+
/**
|
|
1102
|
+
* Ends the engine's frames: with the failure that ended them, which `engine.firstFrame` then
|
|
1103
|
+
* rejects with when the GPU has not finished the first frame, or with none for a stop.
|
|
1104
|
+
*/
|
|
1105
|
+
const endDrawing = (failure) => {
|
|
945
1106
|
if (drawingEnded)
|
|
946
1107
|
return;
|
|
947
1108
|
drawingEnded = true;
|
|
1109
|
+
endCheck();
|
|
1110
|
+
firstFrame.stopped(firstFrameDone(), failure);
|
|
948
1111
|
const handlers = [...stopHandlers];
|
|
949
1112
|
stopHandlers.clear();
|
|
950
1113
|
// The other handlers and the stop go on past one that throws.
|
|
@@ -966,6 +1129,8 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
966
1129
|
sketchErrorHandlers.add(options.onSketchError);
|
|
967
1130
|
/** Where a start that checks its preset keeps the check's result for later starts. */
|
|
968
1131
|
let checkStore;
|
|
1132
|
+
/** The stored list of the first frame's pipelines, on a start that keeps one. */
|
|
1133
|
+
let pipelineStore;
|
|
969
1134
|
/**
|
|
970
1135
|
* Ends the start when the caller cancels it, or when a thread fails before the engine has
|
|
971
1136
|
* started. A thread that fails then, such as the one that draws, leaves the start waiting for
|
|
@@ -975,7 +1140,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
975
1140
|
let starting = true;
|
|
976
1141
|
const cancelStart = () => start.abort(signal?.reason);
|
|
977
1142
|
signal?.addEventListener('abort', cancelStart, { once: true });
|
|
978
|
-
const onFailure = (error, endsStart = true) => {
|
|
1143
|
+
const onFailure = (error, endsStart = true, endsHold = true) => {
|
|
979
1144
|
if (reported.has(error.message))
|
|
980
1145
|
return;
|
|
981
1146
|
reported.add(error.message);
|
|
@@ -983,12 +1148,18 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
983
1148
|
start.abort(error);
|
|
984
1149
|
return;
|
|
985
1150
|
}
|
|
1151
|
+
// Hold mode reads its frame back after the start. A failure ends that read-back, which then
|
|
1152
|
+
// reports it, unless the frames never needed the thread that failed.
|
|
1153
|
+
const hold = endsHold ? endHold : undefined;
|
|
1154
|
+
hold?.(error);
|
|
986
1155
|
// The failure reaches its handlers, or the console, before the stop handlers hear that the
|
|
987
1156
|
// frames ended, so a page hears why before it hears that.
|
|
988
1157
|
try {
|
|
989
1158
|
if (failureHandlers.size === 0) {
|
|
990
|
-
|
|
991
|
-
|
|
1159
|
+
if (!hold) {
|
|
1160
|
+
earlyFailures.push(error);
|
|
1161
|
+
console.error(error);
|
|
1162
|
+
}
|
|
992
1163
|
}
|
|
993
1164
|
else
|
|
994
1165
|
for (const handler of failureHandlers)
|
|
@@ -996,7 +1167,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
996
1167
|
}
|
|
997
1168
|
finally {
|
|
998
1169
|
if (FAILURES_THAT_END_DRAWING.has(error.code))
|
|
999
|
-
endDrawing();
|
|
1170
|
+
endDrawing(error);
|
|
1000
1171
|
}
|
|
1001
1172
|
};
|
|
1002
1173
|
// The GPU path, the mode and the threads, which the start sets once the probe has run. The
|
|
@@ -1015,16 +1186,21 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1015
1186
|
sketchError: onSketchError,
|
|
1016
1187
|
failure: onFailure,
|
|
1017
1188
|
// The page applies the settings that it owns: the pixel ratio cap sizes the canvas. The
|
|
1018
|
-
// engine's mode reports the preset and the preset check, which the page stores for
|
|
1019
|
-
// starts.
|
|
1189
|
+
// engine's mode reports the preset and the preset check's result, which the page stores for
|
|
1190
|
+
// later starts. It also stores the check's rounds at each lowering, so a page that closes
|
|
1191
|
+
// before the check ends keeps them.
|
|
1020
1192
|
quality: (update) => {
|
|
1021
1193
|
canvasWatch?.setMaxPixelRatio(update.settings.maxPixelRatio);
|
|
1022
1194
|
mode.preset = update.preset;
|
|
1023
|
-
if (
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1195
|
+
if (update.check) {
|
|
1196
|
+
if (update.checked)
|
|
1197
|
+
mode.presetCheck = update.check;
|
|
1198
|
+
checkStore?.save(update.check, maxTarget);
|
|
1199
|
+
}
|
|
1200
|
+
if (update.checked)
|
|
1201
|
+
endCheck();
|
|
1027
1202
|
},
|
|
1203
|
+
pipelineList: (list) => pipelineStore?.save(list),
|
|
1028
1204
|
stats: (show) => statsSwitch.show(show),
|
|
1029
1205
|
labelSlot: (id, table, slot, generation) => pageLabels?.setSlot(id, table, slot, generation),
|
|
1030
1206
|
jobsWanted: (count) => growJobs?.(count),
|
|
@@ -1057,6 +1233,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1057
1233
|
const control = createControlBuffer(threaded, labelCapacity(options.maxLabels), labelCapacity3d(options.maxLabels3d));
|
|
1058
1234
|
const expectedObjects = expectedObjectCount(options.expectedObjects);
|
|
1059
1235
|
const metrics = createMetricsBuffer(threaded, jobWorkers);
|
|
1236
|
+
header = new MetricsReader(metrics);
|
|
1060
1237
|
// The frame figures go on the page as the start makes them, so a test tool can time a start
|
|
1061
1238
|
// that stalls before it publishes anything, and read the sketch's growth, the first draw's
|
|
1062
1239
|
// pipelines and the first frame beside the steps it has noted.
|
|
@@ -1124,16 +1301,31 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1124
1301
|
let drawModule = renderThread === 'main' ? loadDrawModule() : undefined;
|
|
1125
1302
|
/** The worker that keeps the canvas from an engine before, which draws for this one. */
|
|
1126
1303
|
const keptWorker = movedTo ? takeParkedWorker(options.canvas, canvasHold) : undefined;
|
|
1127
|
-
// With worker threads the page starts the workers now. A sketch worker
|
|
1128
|
-
//
|
|
1304
|
+
// With worker threads the page starts the workers now. A live sketch's worker imports the sketch
|
|
1305
|
+
// module as soon as its script runs, while the core downloads. In hold mode, a replay and a
|
|
1306
|
+
// recording it imports the module only after it has started the core and the runner, so the page
|
|
1307
|
+
// gets the module into the browser's cache meanwhile. A live start leaves that download to the
|
|
1308
|
+
// worker's own import, which a second request of the same file would only delay, or double where
|
|
1309
|
+
// the browser does not join two requests of one file.
|
|
1129
1310
|
const threads = threaded
|
|
1130
1311
|
? startWorkers(!sketchOnPage, renderThread === 'render-worker', events, keptWorker && movedTo && { worker: keptWorker, role: movedTo })
|
|
1131
1312
|
: undefined;
|
|
1132
1313
|
if (threads?.sketch) {
|
|
1133
|
-
prefetch(sketchUrl);
|
|
1134
1314
|
// In low-latency mode the sketch worker draws, so it loads the renderer now too.
|
|
1135
1315
|
if (renderThread === 'sketch-worker')
|
|
1136
1316
|
threads.sketch.send({ type: 'load-renderer' });
|
|
1317
|
+
if (moduleFirst)
|
|
1318
|
+
threads.sketch.send({ type: 'load-sketch', url: sketchUrl, pageUrl: pageUrl ?? sketchUrl });
|
|
1319
|
+
else
|
|
1320
|
+
prefetch(sketchUrl);
|
|
1321
|
+
}
|
|
1322
|
+
// The job workers start later, as the sketch's tasks and frames ask for them, and a setup that
|
|
1323
|
+
// loads a model asks at once. Their script downloads now, so the first of them start from the
|
|
1324
|
+
// browser's cache.
|
|
1325
|
+
if (jobWorkers > 0) {
|
|
1326
|
+
const jobScript = workerScriptOf(() => newJobWorker(0));
|
|
1327
|
+
if (jobScript)
|
|
1328
|
+
prefetch(jobScript.href);
|
|
1137
1329
|
}
|
|
1138
1330
|
// What the start sets up, which a stop takes down again, from any point of the start.
|
|
1139
1331
|
let coreMemory;
|
|
@@ -1162,6 +1354,8 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1162
1354
|
/** The worker that holds the canvas, or will once the start moves it there. */
|
|
1163
1355
|
let canvasWorker = movedTo === 'render' ? threads?.render : movedTo ? threads?.sketch : undefined;
|
|
1164
1356
|
let localDrawing;
|
|
1357
|
+
/** What the page started for its renderer right after the probe, until the renderer takes it. */
|
|
1358
|
+
let pageEarly;
|
|
1165
1359
|
let localRunner;
|
|
1166
1360
|
/** Sends the sketch a message, here where the page runs it, or through its worker. */
|
|
1167
1361
|
const sendToSketch = (name, data, transfer = []) => {
|
|
@@ -1256,6 +1450,24 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1256
1450
|
stopJobs();
|
|
1257
1451
|
waitForJobWorkersToLeave(slots);
|
|
1258
1452
|
};
|
|
1453
|
+
/**
|
|
1454
|
+
* Gives the GPU back while the browser keeps the page in its back/forward cache, and takes a new
|
|
1455
|
+
* device when the page shows again, as after a GPU loss. Without it, the cached page holds every
|
|
1456
|
+
* texture and buffer, and a phone or tablet can lack the memory for the next page: a repeat
|
|
1457
|
+
* visit of the same page meets the cached one's GPU memory (D-390). The engine listens only where
|
|
1458
|
+
* it keeps texture copies, which bring every map back on the new device.
|
|
1459
|
+
*/
|
|
1460
|
+
const pageCached = (event) => {
|
|
1461
|
+
if (!event.persisted)
|
|
1462
|
+
return;
|
|
1463
|
+
const cached = event.type === 'pagehide';
|
|
1464
|
+
if (!localDrawing)
|
|
1465
|
+
rendererHost?.send({ type: 'page-cache', cached });
|
|
1466
|
+
else if (cached)
|
|
1467
|
+
localDrawing.enterPageCache();
|
|
1468
|
+
else
|
|
1469
|
+
void localDrawing.leavePageCache();
|
|
1470
|
+
};
|
|
1259
1471
|
/** On the dev server, hands each hot update of WGSL to the thread that runs the sketch. */
|
|
1260
1472
|
const updateShaders = (event) => {
|
|
1261
1473
|
const updates = event.detail;
|
|
@@ -1283,6 +1495,8 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1283
1495
|
stopJobs();
|
|
1284
1496
|
removeMeasurementRelease();
|
|
1285
1497
|
globalThis.removeEventListener?.('pagehide', stopJobsAsPageLeaves);
|
|
1498
|
+
globalThis.removeEventListener?.('pagehide', pageCached);
|
|
1499
|
+
globalThis.removeEventListener?.('pageshow', pageCached);
|
|
1286
1500
|
globalThis.removeEventListener?.(WGSL_UPDATE_EVENT, updateShaders);
|
|
1287
1501
|
statsSwitch.show(false);
|
|
1288
1502
|
for (const slot of [
|
|
@@ -1294,6 +1508,8 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1294
1508
|
])
|
|
1295
1509
|
notifySlot(slots, slot, threads?.sketch?.handle);
|
|
1296
1510
|
await localDrawing?.stop();
|
|
1511
|
+
// A start that stops before the page's renderer took its early device destroys it.
|
|
1512
|
+
void pageEarly?.then((early) => early?.release());
|
|
1297
1513
|
localRunner?.dispose();
|
|
1298
1514
|
videos?.dispose();
|
|
1299
1515
|
input?.listen(false);
|
|
@@ -1408,7 +1624,9 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1408
1624
|
// The engine checks a preset that it chose itself, when a lighter one exists. A preset that the
|
|
1409
1625
|
// page, a switch or hold mode fixes stays as it is. A start after a crash measures again, and
|
|
1410
1626
|
// so does one that ?check=fresh asks to. Otherwise the result of an earlier check of the sketch
|
|
1411
|
-
// on this device and browser gives the preset at once, while it applies.
|
|
1627
|
+
// on this device and browser gives the preset at once, while it applies. The rounds of an
|
|
1628
|
+
// earlier check that never ended give the preset that they lowered to, and this start's check
|
|
1629
|
+
// goes on from them.
|
|
1412
1630
|
const checks = optionPreset === 'auto' &&
|
|
1413
1631
|
switches.preset === undefined &&
|
|
1414
1632
|
hold === undefined &&
|
|
@@ -1418,14 +1636,26 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1418
1636
|
const conditions = checkConditions(report, tier, chosen, switches.fps, maxTarget);
|
|
1419
1637
|
checkStore = new CheckStore(sketchUrl, conditions, width * height);
|
|
1420
1638
|
}
|
|
1421
|
-
const
|
|
1422
|
-
const
|
|
1639
|
+
const stored = switches.freshCheck ? undefined : checkStore?.read();
|
|
1640
|
+
const storedCheck = stored && checkEnded(stored) ? stored : undefined;
|
|
1641
|
+
const preset = stored ? checkedPreset(stored) : chosen;
|
|
1423
1642
|
// Occlusion culling on the GPU needs WebGPU's compute passes. Phones and tablets run it only
|
|
1424
1643
|
// when the page asks.
|
|
1425
1644
|
const gpuOcclusion = tier === 'webgl2'
|
|
1426
1645
|
? false
|
|
1427
1646
|
: gpuOcclusionChoice(deviceKind(presetRequest.hints), pageSettings.gpuOcclusion);
|
|
1428
|
-
|
|
1647
|
+
// A start that crashed the tab twice begins in the lowest tier, as a page's switch does: the
|
|
1648
|
+
// engine has already lowered the preset, and the tier is the last step down (D-382).
|
|
1649
|
+
// The `?tier=off` switch keeps the governor out of the tier, and a start keeps its values.
|
|
1650
|
+
const lowestAllowed = switches.lowestTier !== 'off';
|
|
1651
|
+
const startLowest = lowestAllowed &&
|
|
1652
|
+
(switches.lowestTier === 'lowest' ||
|
|
1653
|
+
(switches.preset === undefined && crashLowest(history.crashed)));
|
|
1654
|
+
const tierSettings = {
|
|
1655
|
+
...pageSettings,
|
|
1656
|
+
gpuOcclusion,
|
|
1657
|
+
...(startLowest ? lowestTierSettings(tier) : {}),
|
|
1658
|
+
};
|
|
1429
1659
|
const textureCapMiB = textureMemoryCap(deviceKind(presetRequest.hints));
|
|
1430
1660
|
const quality = {
|
|
1431
1661
|
preset,
|
|
@@ -1434,7 +1664,12 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1434
1664
|
textureCapMiB,
|
|
1435
1665
|
keepCopies: keepTextureCopies,
|
|
1436
1666
|
highest: withinTier('ultra', tier),
|
|
1437
|
-
|
|
1667
|
+
// A replay steps through its recording, which leaves no frames of play to measure.
|
|
1668
|
+
check: checks && !storedCheck && replay === undefined ? checkTiming : undefined,
|
|
1669
|
+
resume: storedCheck ? undefined : stored,
|
|
1670
|
+
lowest: startLowest,
|
|
1671
|
+
lowestAllowed,
|
|
1672
|
+
tier,
|
|
1438
1673
|
};
|
|
1439
1674
|
mode = {
|
|
1440
1675
|
build,
|
|
@@ -1450,6 +1685,8 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1450
1685
|
renderFallback,
|
|
1451
1686
|
keepTextureCopies,
|
|
1452
1687
|
};
|
|
1688
|
+
if (quality.check === undefined)
|
|
1689
|
+
endCheck();
|
|
1453
1690
|
/**
|
|
1454
1691
|
* The preset that the first frame draws at: the one the engine starts with, because its own
|
|
1455
1692
|
* preset check draws that frame before it can step down. The page can end on a lighter preset,
|
|
@@ -1491,6 +1728,9 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1491
1728
|
globalThis.__null3dStopRecording = stopRecording;
|
|
1492
1729
|
if (recording && renderThread === 'main')
|
|
1493
1730
|
recordPermutations();
|
|
1731
|
+
// The dev server compares each word that the page draws with against the project's list.
|
|
1732
|
+
if (DEV && renderThread === 'main')
|
|
1733
|
+
reportPermutations(announcePermutationWord);
|
|
1494
1734
|
// What the thread that draws needs besides its canvas, whichever thread that is.
|
|
1495
1735
|
const rendererSetup = {
|
|
1496
1736
|
tier,
|
|
@@ -1521,15 +1761,32 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1521
1761
|
expectedObjects,
|
|
1522
1762
|
gpuOcclusion: quality.settings.gpuOcclusion,
|
|
1523
1763
|
});
|
|
1524
|
-
//
|
|
1525
|
-
//
|
|
1526
|
-
|
|
1764
|
+
// A live start keeps the list of its first frame's pipelines, and builds the list that the last
|
|
1765
|
+
// start at the same preset kept as soon as the thread that draws can. A hold, a replay and a
|
|
1766
|
+
// recording of permutation words draw what they hold, so they neither read nor keep one.
|
|
1767
|
+
if (hold === undefined && replay === undefined && !rendererSetup.recordPermutations) {
|
|
1768
|
+
pipelineStore = new PipelineStore(sketchUrl, pipelineConditions(tier, device.shaderBits, preset, tier === 'webgl2' ? undefined : (report.webgpu.preferredCanvasFormat ?? undefined)));
|
|
1769
|
+
rendererSetup.keepBuilds = true;
|
|
1770
|
+
if (!switches.freshBuilds)
|
|
1771
|
+
rendererSetup.earlyBuilds = pipelineStore.read();
|
|
1772
|
+
}
|
|
1773
|
+
// The GPU path and the device choose the renderers and the shader files that the thread that
|
|
1774
|
+
// draws loads first, and the GPU device that it asks for, so it starts them now, while the core
|
|
1775
|
+
// downloads.
|
|
1776
|
+
const drawingPreload = {
|
|
1777
|
+
tier,
|
|
1778
|
+
device,
|
|
1779
|
+
forceCompat,
|
|
1780
|
+
powerPreference,
|
|
1781
|
+
preload: options.preload,
|
|
1782
|
+
};
|
|
1783
|
+
const shaderPreload = { type: 'load-shaders', ...drawingPreload };
|
|
1527
1784
|
if (renderThread === 'render-worker')
|
|
1528
1785
|
threads?.render?.send(shaderPreload);
|
|
1529
1786
|
else if (renderThread === 'sketch-worker')
|
|
1530
1787
|
threads?.sketch?.send(shaderPreload);
|
|
1531
1788
|
else if (drawModule)
|
|
1532
|
-
|
|
1789
|
+
pageEarly = preloadDrawing(drawModule, drawingPreload);
|
|
1533
1790
|
const core = await abortable(coreLoad, signal);
|
|
1534
1791
|
coreMemory = core.memory;
|
|
1535
1792
|
memoryKey = core.memoryKey;
|
|
@@ -1608,11 +1865,14 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1608
1865
|
*/
|
|
1609
1866
|
const drawOnPage = async (memory, images, sketch) => {
|
|
1610
1867
|
draw = await (drawModule ?? loadDrawModule());
|
|
1868
|
+
const early = await pageEarly;
|
|
1869
|
+
pageEarly = undefined;
|
|
1611
1870
|
// The page's context stays with the canvas: an engine after this one draws on the page too.
|
|
1612
1871
|
canvasHold.pageContext = true;
|
|
1613
1872
|
return draw.startDrawing({
|
|
1614
1873
|
canvas: options.canvas,
|
|
1615
1874
|
...rendererSetup,
|
|
1875
|
+
early,
|
|
1616
1876
|
metrics,
|
|
1617
1877
|
device,
|
|
1618
1878
|
scene: memory && { memory, control },
|
|
@@ -1620,13 +1880,18 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1620
1880
|
sketch,
|
|
1621
1881
|
...images,
|
|
1622
1882
|
presented: () => labels.update(),
|
|
1883
|
+
listBuilds: rendererSetup.keepBuilds ? (list) => pipelineStore?.save(list) : undefined,
|
|
1623
1884
|
fail: pageLoss,
|
|
1624
1885
|
fault: (error) => onFailure(failureError('the drawing on the page', messageOf(error))),
|
|
1625
|
-
gpuError: (
|
|
1886
|
+
gpuError: (kind, message) => onFailure(gpuFailure('the page', kind, message), false),
|
|
1626
1887
|
});
|
|
1627
1888
|
};
|
|
1628
1889
|
if (threads && jobWorkers > 0)
|
|
1629
1890
|
globalThis.addEventListener?.('pagehide', stopJobsAsPageLeaves);
|
|
1891
|
+
if (keepTextureCopies && hold === undefined) {
|
|
1892
|
+
globalThis.addEventListener?.('pagehide', pageCached);
|
|
1893
|
+
globalThis.addEventListener?.('pageshow', pageCached);
|
|
1894
|
+
}
|
|
1630
1895
|
if (DEV)
|
|
1631
1896
|
globalThis.addEventListener?.(WGSL_UPDATE_EVENT, updateShaders);
|
|
1632
1897
|
/**
|
|
@@ -1642,14 +1907,34 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1642
1907
|
const taskPorts = Array.from({ length: jobWorkers }, () => channel());
|
|
1643
1908
|
/** The job workers that started, by index, which the on-demand loader sends its tasks to. */
|
|
1644
1909
|
const running = [];
|
|
1645
|
-
/**
|
|
1646
|
-
|
|
1910
|
+
/**
|
|
1911
|
+
* Tells the thread that runs the sketch which job workers run, in a new list each time. A
|
|
1912
|
+
* sketch on this page reads the news itself, since no sketch worker carries it.
|
|
1913
|
+
*/
|
|
1914
|
+
const tell = () => {
|
|
1915
|
+
running.sort((a, b) => a - b);
|
|
1916
|
+
threads?.sketch?.send({ type: 'job-workers', running: [...running] });
|
|
1917
|
+
if (jobTaskHost)
|
|
1918
|
+
jobTaskHost.running = [...running];
|
|
1919
|
+
};
|
|
1647
1920
|
growJobs = (count) => {
|
|
1921
|
+
// The sketch thread hears of each job worker as soon as it is ready, so its first task
|
|
1922
|
+
// runs on the first that is, and only on workers that run. A batch none of whose workers
|
|
1923
|
+
// started still says so once it has settled, so a task that waits for them goes to a
|
|
1924
|
+
// task worker instead. A batch that started no worker at all, because the browser
|
|
1925
|
+
// refused them or the engine is stopping, stays unheard: the thread then uses the
|
|
1926
|
+
// workers it asked for.
|
|
1927
|
+
let heard = false;
|
|
1928
|
+
const started = (index) => {
|
|
1929
|
+
heard = true;
|
|
1930
|
+
running.push(index);
|
|
1931
|
+
tell();
|
|
1932
|
+
};
|
|
1648
1933
|
const starting = [];
|
|
1649
1934
|
for (let index = jobs.length; index < Math.min(count, jobWorkers); index++) {
|
|
1650
1935
|
if (Atomics.load(slots, Slot.Running) === 0)
|
|
1651
1936
|
break;
|
|
1652
|
-
const job = startJobWorker(index, slots, events,
|
|
1937
|
+
const job = startJobWorker(index, slots, events, started);
|
|
1653
1938
|
if (!job)
|
|
1654
1939
|
break;
|
|
1655
1940
|
jobs.push(job);
|
|
@@ -1657,18 +1942,11 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1657
1942
|
job.send({ type: 'init', ...handoff, index, taskPort: port }, [port]);
|
|
1658
1943
|
starting.push(job.ready());
|
|
1659
1944
|
}
|
|
1660
|
-
// The sketch thread hears which of a batch of job workers run once the whole batch has
|
|
1661
|
-
// settled, so it never takes a worker for running before the batch is known. A batch
|
|
1662
|
-
// that started no worker, because the browser refused them or the engine is stopping,
|
|
1663
|
-
// stays unheard: the thread then uses the workers it asked for. A sketch on this page
|
|
1664
|
-
// reads the news itself, since no sketch worker carries it.
|
|
1665
1945
|
if (starting.length === 0)
|
|
1666
1946
|
return;
|
|
1667
1947
|
void Promise.allSettled(starting).then(() => {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
if (jobTaskHost)
|
|
1671
|
-
jobTaskHost.running = [...running];
|
|
1948
|
+
if (!heard)
|
|
1949
|
+
tell();
|
|
1672
1950
|
});
|
|
1673
1951
|
};
|
|
1674
1952
|
return taskPorts.map((tasks) => tasks.port2);
|
|
@@ -1753,6 +2031,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1753
2031
|
...senders,
|
|
1754
2032
|
pageUrl: pageUrl ?? sketchUrl,
|
|
1755
2033
|
sketchUrl,
|
|
2034
|
+
data: modes.sketchData,
|
|
1756
2035
|
maxTargetFps: maxTarget,
|
|
1757
2036
|
threads: engineThreads,
|
|
1758
2037
|
twoStepProbe: DEV && switches.twoStep,
|
|
@@ -1760,19 +2039,15 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1760
2039
|
wantJobs,
|
|
1761
2040
|
sendLabelSlot: events.labelSlot,
|
|
1762
2041
|
reportSketchError: (message) => events.sketchError(new Error(message)),
|
|
2042
|
+
listed: sketchModule ? listed : undefined,
|
|
1763
2043
|
// What the sketch's module loaded before the runner existed, then each later load.
|
|
1764
2044
|
...(DEV && {
|
|
1765
|
-
hearAddons: (heard) =>
|
|
1766
|
-
stopEarlyAddons?.();
|
|
1767
|
-
for (const name of earlyAddons ?? [])
|
|
1768
|
-
heard(name);
|
|
1769
|
-
return onAddonChecked(heard);
|
|
1770
|
-
},
|
|
2045
|
+
hearAddons: (heard) => earlyAddons?.hand(heard) ?? onAddonChecked(heard),
|
|
1771
2046
|
}),
|
|
1772
2047
|
}, hold, holdScript, replay, record, switches.view);
|
|
1773
|
-
// In hold mode the sketch module loads only now, after the runner
|
|
1774
|
-
// numbers. The renderer starts before the setup, so a warm-up in the
|
|
1775
|
-
// to build its pipelines.
|
|
2048
|
+
// In hold mode, a replay and a recording the sketch module loads only now, after the runner
|
|
2049
|
+
// seeded the random numbers. The renderer starts before the setup, so a warm-up in the
|
|
2050
|
+
// setup has a renderer to build its pipelines.
|
|
1776
2051
|
const sketchLoad = sketchModule ?? awaitLater(loadSketch(sketchUrl));
|
|
1777
2052
|
if (!render)
|
|
1778
2053
|
localDrawing = await abortable(drawOnPage(memory, { imageTable }, localRunner), start.signal);
|
|
@@ -1803,6 +2078,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1803
2078
|
...handoff,
|
|
1804
2079
|
sketchUrl,
|
|
1805
2080
|
pageUrl: pageUrl ?? sketchUrl,
|
|
2081
|
+
data: modes.sketchData,
|
|
1806
2082
|
keyCodes: KEY_CODES,
|
|
1807
2083
|
jobWorkers,
|
|
1808
2084
|
capabilities,
|
|
@@ -1844,24 +2120,23 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1844
2120
|
const engineStartMs = performance.now() - startedAt;
|
|
1845
2121
|
onProgress('sketch');
|
|
1846
2122
|
// The thread that draws writes the time the GPU finished the first frame; the page checks for
|
|
1847
|
-
// it once per animation frame until it appears.
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
return;
|
|
1857
|
-
}
|
|
1858
|
-
requestAnimationFrame(check);
|
|
1859
|
-
};
|
|
2123
|
+
// it once per animation frame until it appears, or until the engine stops drawing.
|
|
2124
|
+
const check = () => {
|
|
2125
|
+
if (Atomics.load(slots, Slot.Running) === 0)
|
|
2126
|
+
return;
|
|
2127
|
+
if (firstFrameDone()) {
|
|
2128
|
+
onProgress('first-frame');
|
|
2129
|
+
firstFrame.drawn();
|
|
2130
|
+
return;
|
|
2131
|
+
}
|
|
1860
2132
|
requestAnimationFrame(check);
|
|
1861
|
-
}
|
|
1862
|
-
|
|
2133
|
+
};
|
|
2134
|
+
requestAnimationFrame(check);
|
|
2135
|
+
// The note covers the preset check as well as the first seconds of play, so a start whose
|
|
2136
|
+
// check ends in a crash counts as one.
|
|
2137
|
+
marker?.endAfter(Promise.all([firstFrame.promise, presetChecked]).then(() => undefined));
|
|
1863
2138
|
if (DEV && switches.twoStep)
|
|
1864
|
-
void firstFrame.then(() => logTwoStep(slots, false));
|
|
2139
|
+
void firstFrame.promise.then(() => logTwoStep(slots, false), () => { });
|
|
1865
2140
|
/** Hold mode's frame, read back once. */
|
|
1866
2141
|
let held;
|
|
1867
2142
|
/** The error of a thread that draws when it could not capture a frame. */
|
|
@@ -1895,13 +2170,40 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1895
2170
|
throw captureFailure(reply);
|
|
1896
2171
|
};
|
|
1897
2172
|
const stopped = () => Atomics.load(slots, Slot.Running) === 0;
|
|
2173
|
+
/**
|
|
2174
|
+
* The development build's inspection bridge: a capture reads the current frame here, and
|
|
2175
|
+
* every other call runs in the thread that runs the sketch. A release build defines none,
|
|
2176
|
+
* so code that uses it checks for it first.
|
|
2177
|
+
*/
|
|
2178
|
+
const inspectCall = DEV
|
|
2179
|
+
? async (call, args) => {
|
|
2180
|
+
if (call === 'capture') {
|
|
2181
|
+
const blob = await captureImage();
|
|
2182
|
+
const url = await new Promise((resolve, reject) => {
|
|
2183
|
+
const reader = new FileReader();
|
|
2184
|
+
reader.onload = () => resolve(reader.result);
|
|
2185
|
+
reader.onerror = () => reject(reader.error);
|
|
2186
|
+
reader.readAsDataURL(blob);
|
|
2187
|
+
});
|
|
2188
|
+
return { png: url.slice(url.indexOf(',') + 1), bytes: blob.size };
|
|
2189
|
+
}
|
|
2190
|
+
if (localRunner?.inspect !== undefined)
|
|
2191
|
+
return await localRunner.inspect(call, args);
|
|
2192
|
+
const worker = threads?.sketch;
|
|
2193
|
+
if (worker === undefined)
|
|
2194
|
+
throw new Error('the sketch worker is not running, so the inspector has nothing to read');
|
|
2195
|
+
return await worker.inspect(call, args);
|
|
2196
|
+
}
|
|
2197
|
+
: undefined;
|
|
1898
2198
|
const engine = {
|
|
1899
2199
|
capabilities,
|
|
1900
2200
|
report,
|
|
1901
2201
|
mode,
|
|
1902
|
-
firstFrame,
|
|
2202
|
+
firstFrame: firstFrame.promise,
|
|
2203
|
+
presetChecked,
|
|
1903
2204
|
labels,
|
|
1904
2205
|
postToSketch: sendToSketch,
|
|
2206
|
+
...(inspectCall === undefined ? {} : { inspect: inspectCall }),
|
|
1905
2207
|
registerVideo: (video, videoOptions) => videos.register(video, videoOptions),
|
|
1906
2208
|
onSketchMessage(handler) {
|
|
1907
2209
|
messageHandlers.add(handler);
|
|
@@ -1956,7 +2258,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1956
2258
|
// adds an object then builds its pipelines while the figures load.
|
|
1957
2259
|
const reader = new MetricsReader(metrics);
|
|
1958
2260
|
reader.begin();
|
|
1959
|
-
const { HeapSampler, secondRates, slowFrames, summarizeFrames, wasmDownloadBytes } = await loadFrameStats();
|
|
2261
|
+
const { HeapSampler, drawingStartFigures, secondRates, slowFrames, summarizeFrames, wasmDownloadBytes, } = await loadFrameStats();
|
|
1960
2262
|
const mainThread = new MainThreadWatch();
|
|
1961
2263
|
const started = performance.now();
|
|
1962
2264
|
const heap = new HeapSampler();
|
|
@@ -1982,6 +2284,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
1982
2284
|
firstDrawMs: reader.firstDrawMs,
|
|
1983
2285
|
firstFramePipelines: reader.firstFramePipelines,
|
|
1984
2286
|
firstFramePreset,
|
|
2287
|
+
drawingStart: drawingStartFigures(reader),
|
|
1985
2288
|
},
|
|
1986
2289
|
gpuLosses: Atomics.load(slots, Slot.GpuEpoch),
|
|
1987
2290
|
downloadBytes: { wasm: wasmDownloadBytes() },
|
|
@@ -2052,6 +2355,36 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
2052
2355
|
if (hold === undefined && replay === undefined) {
|
|
2053
2356
|
if (switches.bench)
|
|
2054
2357
|
globalThis[BENCH_GLOBAL] = engine;
|
|
2358
|
+
if (DEV && inspectCall !== undefined) {
|
|
2359
|
+
// The page publishes the bridge so the MCP server and a developer's console can call
|
|
2360
|
+
// it. The switch opens the panel, whose code loads on first use. A stopped engine
|
|
2361
|
+
// takes the bridge away, so the page keeps none of its memory.
|
|
2362
|
+
globalThis[INSPECTOR_GLOBAL] = {
|
|
2363
|
+
inspect: inspectCall,
|
|
2364
|
+
engine,
|
|
2365
|
+
};
|
|
2366
|
+
engine.onStop(() => {
|
|
2367
|
+
const current = globalThis[INSPECTOR_GLOBAL];
|
|
2368
|
+
if (current?.engine === engine)
|
|
2369
|
+
delete globalThis[INSPECTOR_GLOBAL];
|
|
2370
|
+
});
|
|
2371
|
+
if (switches.inspect)
|
|
2372
|
+
void (async () => {
|
|
2373
|
+
// The panel's file loads from its source address. A development build runs the source,
|
|
2374
|
+
// whose file is TypeScript; the published package holds the compiled JavaScript. A
|
|
2375
|
+
// production build removes this branch, and emits no file for it.
|
|
2376
|
+
const extension = new URL(import.meta.url).pathname.endsWith('.ts') ? 'ts' : 'js';
|
|
2377
|
+
const source = `../debug/inspector.${extension}`;
|
|
2378
|
+
const url = new URL(source, import.meta.url).href;
|
|
2379
|
+
const module = (await import(__rewriteRelativeImportExtension(
|
|
2380
|
+
/* @vite-ignore */ url)));
|
|
2381
|
+
const inspector = module.openInspector({
|
|
2382
|
+
inspect: inspectCall,
|
|
2383
|
+
canvas: options.canvas,
|
|
2384
|
+
});
|
|
2385
|
+
engine.onStop(() => inspector.remove());
|
|
2386
|
+
})().catch((error) => console.warn('null3D could not show the inspector:', error));
|
|
2387
|
+
}
|
|
2055
2388
|
// The switch's start state goes on top of the option's corner.
|
|
2056
2389
|
if (switches.stats !== false) {
|
|
2057
2390
|
if (options.stats)
|
|
@@ -2062,7 +2395,12 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
2062
2395
|
return engine;
|
|
2063
2396
|
}
|
|
2064
2397
|
try {
|
|
2065
|
-
held = await abortable(holdFrame(capture,
|
|
2398
|
+
held = await abortable(holdFrame(capture, (end) => {
|
|
2399
|
+
endHold = end;
|
|
2400
|
+
return () => {
|
|
2401
|
+
endHold = undefined;
|
|
2402
|
+
};
|
|
2403
|
+
}), signal);
|
|
2066
2404
|
// The held frame built every pipeline that the scene draws with, so its words are
|
|
2067
2405
|
// complete here, before the page publishes the frame the tool waits on.
|
|
2068
2406
|
stopRecording();
|
|
@@ -2113,15 +2451,16 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
|
|
|
2113
2451
|
}
|
|
2114
2452
|
/**
|
|
2115
2453
|
* Draws the held frame and reads it back through `capture`. The first failure that the engine
|
|
2116
|
-
* reports meanwhile, such as a lost GPU, ends the hold
|
|
2454
|
+
* reports meanwhile to the function that `listen` registers, such as a lost GPU, ends the hold
|
|
2455
|
+
* instead. `listen` returns the function that ends the listening. A failure without a code becomes
|
|
2117
2456
|
* E1408.
|
|
2118
2457
|
*/
|
|
2119
|
-
async function holdFrame(capture,
|
|
2458
|
+
async function holdFrame(capture, listen) {
|
|
2120
2459
|
let fail = () => { };
|
|
2121
2460
|
const failed = new Promise((_, reject) => {
|
|
2122
2461
|
fail = reject;
|
|
2123
2462
|
});
|
|
2124
|
-
|
|
2463
|
+
const stopListening = listen(fail);
|
|
2125
2464
|
try {
|
|
2126
2465
|
return await Promise.race([capture(), failed]);
|
|
2127
2466
|
}
|
|
@@ -2131,6 +2470,6 @@ async function holdFrame(capture, failureHandlers) {
|
|
|
2131
2470
|
throw new EngineError('E1408', `hold mode stopped before it read the held frame back: ${messageOf(error)}.`);
|
|
2132
2471
|
}
|
|
2133
2472
|
finally {
|
|
2134
|
-
|
|
2473
|
+
stopListening();
|
|
2135
2474
|
}
|
|
2136
2475
|
}
|