release: v3.26.150 Canvas V3 异常兜底 + 7000 节点数据

This commit is contained in:
qiqi committed 2026-12-01 01:15:25 +08:00
1 parent bb6c8d9772
commit 35e68c7508
12 files changed
+69 -44

No files matched your search

+12 -2
View File
@@ -47,7 +47,7 @@
return entry
}
function draw (canvas, o) {
function drawUnsafe (canvas, o) {
if (!canvas || !o || typeof canvas.getContext !== 'function') return
const t0 = (typeof performance !== 'undefined' && performance.now) ? performance.now() : 0
const rect = canvas.getBoundingClientRect ? canvas.getBoundingClientRect() : null
@@ -203,6 +203,16 @@
if (t0) { perf.lastMs = (typeof performance !== 'undefined' && performance.now ? performance.now() : t0) - t0; perf.frames++ }
}
// 单帧绘制失败不能冒泡到 React effect;记录后保留上一帧,下一帧重试。
function draw (canvas, o) {
try {
drawUnsafe(canvas, o)
perf.lastError = ''
} catch (e) {
perf.lastError = String((e && e.message) || e)
}
}
function CanvasNodeLayer (props) {
const ref = useRef(null)
const latest = useRef(props)
@@ -225,6 +235,6 @@
return el('canvas', { className: 'iwb-node-canvas', 'aria-hidden': 'true', ref: ref })
}
function stats () { return { drawMs: perf.lastMs, frames: perf.frames, images: imgCache.size } }
function stats () { return { drawMs: perf.lastMs, frames: perf.frames, images: imgCache.size, error: perf.lastError || '' } }
global.IWBCanvasV3NodeLayer = { CanvasNodeLayer, draw, stats }
})(typeof window !== 'undefined' ? window : globalThis)