The Rust-side NodeRef gate (previous commit) didn't actually close the race on fast client-side re-navigation back to / - reproduced the same crash again after that fix shipped. Harden the actual failure point directly instead of chasing the exact Leptos/wasm-bindgen timing: skip setup (not throw) if either canvas is missing.
This commit is contained in:
@@ -11,6 +11,22 @@ export class RasterizedYES {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.rasterCanvas = document.getElementById('rasterCanvas');
|
this.rasterCanvas = document.getElementById('rasterCanvas');
|
||||||
this.lineCanvas = document.getElementById('lineCanvas');
|
this.lineCanvas = document.getElementById('lineCanvas');
|
||||||
|
|
||||||
|
// The Rust side only constructs this once it's confirmed (via a
|
||||||
|
// NodeRef) that the canvas is mounted, but that guard has shown
|
||||||
|
// a real gap on fast client-side re-navigation back to `/` -
|
||||||
|
// this is the actual failure point, so it gets its own defense
|
||||||
|
// rather than depending on getting that timing exactly right
|
||||||
|
// from the other side of the wasm boundary. Leaving the
|
||||||
|
// instance otherwise-inert (no crash, no animation) rather than
|
||||||
|
// throwing mid-render - `stop()` already tolerates a partially
|
||||||
|
// (non-)initialized instance.
|
||||||
|
if (!this.rasterCanvas || !this.lineCanvas) {
|
||||||
|
console.warn('RasterizedYES: canvas not in DOM yet, skipping');
|
||||||
|
this.destroyed = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.rasterCtx = this.rasterCanvas.getContext('2d');
|
this.rasterCtx = this.rasterCanvas.getContext('2d');
|
||||||
this.lineCtx = this.lineCanvas.getContext('2d');
|
this.lineCtx = this.lineCanvas.getContext('2d');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user