@expofp/renderer 3.42.1 → 3.43.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.
- package/dist/Renderer.js +26 -1
- package/package.json +2 -2
package/dist/Renderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { StrictMode, Suspense } from 'react';
|
|
2
|
+
import { StrictMode, Suspense, useEffect, useRef, } from 'react';
|
|
3
3
|
import { Controls } from './controls';
|
|
4
4
|
import { CanvasWithDebug, DebugOverlay } from './debug';
|
|
5
5
|
import { PointerMissed } from './events/PointerMissed';
|
|
@@ -27,6 +27,27 @@ export function Renderer(props) {
|
|
|
27
27
|
const { debug, scene, memoryLimit, minZoom, maxZoom, minPitch, maxPitch, bounds, smoothTime, controls, lighting, visibleRect, onPointerMissed, gl, requestFrame, onFrame, children, ...canvasProps } = props;
|
|
28
28
|
const cameraProps = { minZoom, maxZoom, minPitch, maxPitch, bounds, smoothTime };
|
|
29
29
|
const external = gl !== undefined;
|
|
30
|
+
// The context this mount created, released here rather than left to R3F. `<Canvas>`'s teardown
|
|
31
|
+
// (`unmountComponentAtNode`) defers `forceContextLoss()` behind a 500 ms `setTimeout`, inside a
|
|
32
|
+
// `try` that disconnects events first — so a host that unmounts the renderer holds a full
|
|
33
|
+
// viewport of GPU memory for half a second after it thought the surface was gone, and holds it
|
|
34
|
+
// forever if anything ahead of the loss in that block throws. An SDK `destroy()` that returns
|
|
35
|
+
// while the plan still owns a WebGL2 context is the same bug on a timer, and a plan swap pays it
|
|
36
|
+
// as a real transient: the incoming plan's context is created while the outgoing one still
|
|
37
|
+
// holds its own. R3F's deferred pass still runs afterwards and is unharmed — its remaining work
|
|
38
|
+
// (`renderLists.dispose()`, `dispose(scene)`) is no-ops on a lost context.
|
|
39
|
+
//
|
|
40
|
+
// Safe as a plain unmount effect only because `<StrictMode>` starts *below* here, wrapping the
|
|
41
|
+
// canvas rather than this component: nothing simulates a remount at this level, so the cleanup
|
|
42
|
+
// runs when the renderer is actually going away. External mode never fills the ref — the host
|
|
43
|
+
// owns that context, and `ExternalCanvas` neuters `forceContextLoss` for the same reason.
|
|
44
|
+
const rendererRef = useRef(undefined);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
return () => {
|
|
47
|
+
rendererRef.current?.forceContextLoss();
|
|
48
|
+
rendererRef.current = undefined;
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
30
51
|
// The one tree, whichever canvas it lands on. The mount decides nothing about it; the tree
|
|
31
52
|
// leaves out what external mode has no object for — the controls here, the camera inside Scene.
|
|
32
53
|
const tree = (_jsx(DebugOverlay, { enabled: debug, children: _jsxs(Scene, { sceneDef: scene, external: external, memoryLimit: memoryLimit, lighting: lighting, visibleRect: visibleRect, ...cameraProps, children: [!external && _jsx(Controls, { config: controls }), _jsx(PointerMissed, { onPointerMissed: onPointerMissed }), children] }) }));
|
|
@@ -59,7 +80,11 @@ export function Renderer(props) {
|
|
|
59
80
|
// a compile synchronous: 17 programs cost 64 ms of main thread on a large scene, in
|
|
60
81
|
// blocks of up to 12 ms, and they land in the frames where the layers are still mounting.
|
|
61
82
|
// Debug keeps the check, because a broken shader has to report itself somewhere.
|
|
83
|
+
//
|
|
84
|
+
// The root state is also this mount's one handle on the renderer, which the unmount
|
|
85
|
+
// effect above needs to release its context.
|
|
62
86
|
onCreated: (state) => {
|
|
63
87
|
state.gl.debug.checkShaderErrors = debug ?? false;
|
|
88
|
+
rendererRef.current = state.gl;
|
|
64
89
|
}, frameloop: debug ? 'always' : 'demand', resize: { debounce: 50 }, children: tree }) }) }));
|
|
65
90
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expofp/renderer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.43.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/expofp/efp-app.git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"troika-three-text": "^0.52.5",
|
|
43
43
|
"tslib": "^2.3.0",
|
|
44
44
|
"webgl-memory": "^1.1.3",
|
|
45
|
-
"@expofp/geometry": "3.
|
|
45
|
+
"@expofp/geometry": "3.43.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@react-three/test-renderer": "^9.1.0",
|