[118] Kern: Neustart nach Panic, Projekt aus der Leseansicht wiederhergestellt

core() hüllt alle Kern-Exporte; ein WASM-Trap baut sofort eine frische Instanz
(__dossier_reinit, ergänzt von scripts/build-core.mjs), alle ProjectDocuments
öffnen sich aus ihrer Leseansicht neu, Kern-Handles gelten über coreEpoch() als
ungültig. Der Aufruf wirft CoreTrapError (keine Wiederholung); die Hülle legt
eine Autosave-Kopie an und meldet (Verlauf geleert). Test über verstecktes
__debug_panic.
This commit is contained in:
Claude committed 2026-11-03 17:44:12 +00:00
1 parent bb3d9ede38
commit d9ee776618
17 files changed
+383 -13

No files matched your search

+3
View File
@@ -25,6 +25,7 @@ import type {
Vec2,
} from "../model/types";
import { documentFor } from "../core/document";
import { registerCoreRestore } from "../engine/coreWasm";
import { decodePlanBuf, type DecodedPlanBuf } from "./planBuf";
import {
SHOW_ALL,
@@ -440,6 +441,8 @@ const PLAN_MULTI_MAGIC = 1_347_175_021;
*/
const chunkStores = new Map<string, Map<number, DecodedPlanBuf>>();
const MAX_CHUNK_STORES = 16;
// Der Kern-Cache der Stücke ist nach einem Kern-Neustart leer ([118]): alles neu anfordern.
registerCoreRestore(() => chunkStores.clear());
const DETAIL_CODE: Record<DetailLevel, number> = { grob: 0, mittel: 1, fein: 2 };
+3 -1
View File
@@ -14,7 +14,7 @@ import type { Primitive } from '../generatePlan';
import type { Vec2 } from '../../model/types';
import type { BufferGl, DashBatch, GpuGeometry, Rgba } from './glPlanTypes';
import { encodePlanBuf, type DecodedPlanBuf } from '../planBuf';
import { core } from '../../engine/coreWasm';
import { core, coreEpoch } from '../../engine/coreWasm';
/**
* Ear-Clipping-Triangulierung eines einfachen (lochfreien) Polygons, konvex oder konkav.
@@ -54,9 +54,11 @@ export function compilePrimitivesToGpu(
export function compilePlanBufRange(gl: BufferGl, src: DecodedPlanBuf, from: number, to: number, pxPerMeter = 0): GpuGeometry {
const packed = gl.packedLineVertices === true;
const c = core();
if (src.holdEpoch !== coreEpoch()) src.hold = 0; // Nummer aus einer Kern-Instanz vor dem Neustart ([118])
let out = src.hold ? c.gpu_compile_held(src.hold, from, to, pxPerMeter, packed) : new Uint32Array(0);
if (out.length === 0) {
src.hold = c.plan_buf_hold(src.bytes);
src.holdEpoch = coreEpoch();
out = src.hold ? c.gpu_compile_held(src.hold, from, to, pxPerMeter, packed) : c.gpu_compile_flat(src.bytes, from, to, pxPerMeter, packed);
}
return uploadCompiled(gl, out);
+2
View File
@@ -479,6 +479,8 @@ export interface DecodedPlanBuf {
hashes: Float64Array | null;
/** Nummer des im Kern gehaltenen Puffers (0 = keiner), s. `compilePlanBufRange`. */
hold: number;
/** Kern-Epoche, in der `hold` vergeben wurde (nach einem Kern-Neustart ungültig, [118]). */
holdEpoch?: number;
}
function unitsToString(u: Uint16Array): string {
+11 -2
View File
@@ -14,12 +14,14 @@
import type { Plan, PlanBufRun, Primitive } from "./generatePlan";
import { encodePlanBuf } from "./planBuf";
import { isBufPiece, lazyPieces, type PlanPiece } from "./planLazy";
import { core } from "../engine/coreWasm";
import { core, coreEpoch } from "../engine/coreWasm";
/** Ein im Kern ablegbarer Puffer (Kern-Ergebnis `DecodedPlanBuf` oder eigener). */
interface HoldableBuf {
bytes: Uint8Array;
hold: number;
/** Kern-Epoche von `hold` ([118], `coreEpoch`). */
holdEpoch?: number;
}
export interface PlanParts {
@@ -171,7 +173,14 @@ export function heldSegs(parts: PlanParts, fresh: boolean): Float64Array {
// Eine Runde: die Puffer dieses Plans (viele Zeichnungs-Stücke) verdrängen sich nicht gegenseitig.
c.plan_buf_round_begin();
try {
for (const b of parts.bufs) if (!b.hold || ((fresh || parts.bufs.length > 1) && !c.plan_buf_touch(b.hold))) b.hold = c.plan_buf_hold(b.bytes);
const ep = coreEpoch();
for (const b of parts.bufs) {
if (b.holdEpoch !== ep) b.hold = 0; // Nummer aus einer Kern-Instanz vor dem Neustart ([118])
if (!b.hold || ((fresh || parts.bufs.length > 1) && !c.plan_buf_touch(b.hold))) {
b.hold = c.plan_buf_hold(b.bytes);
b.holdEpoch = ep;
}
}
} finally {
c.plan_buf_round_end();
}
+6 -3
View File
@@ -11,7 +11,7 @@ import type { Vec2 } from "../../model/types";
import type { Plan, Primitive } from "../generatePlan";
import { heldSegs, planParts } from "../planParts";
import { planPrimAt } from "../planLazy";
import { core } from "../../engine/coreWasm";
import { core, coreEpoch } from "../../engine/coreWasm";
import type { ModelRect } from "./geometry";
/** Pick-Felder eines Primitivs (Besitzer-Ids). */
@@ -77,6 +77,8 @@ const splitIds = (s: string): string[] => (s ? s.split("\0").slice(1) : []);
export class PlanPickIndex {
private id = 0;
/** Kern-Epoche des Index (nach einem Kern-Neustart neu bauen, [118]). */
private epoch = 0;
constructor(readonly plan: Plan) {}
@@ -87,7 +89,8 @@ export class PlanPickIndex {
/** Kern-Index (lazy beim ersten Abfragen gebaut). Texte/Bilder mit JSON (Rahmen-Treffer). */
private ix(): number {
if (this.id) return this.id;
if (this.id && this.epoch === coreEpoch()) return this.id;
this.epoch = coreEpoch();
const c = core();
const parts = planParts(this.plan, true);
this.id = c.pick_index_build(heldSegs(parts, false));
@@ -97,7 +100,7 @@ export class PlanPickIndex {
/** Kern-Index freigeben (danach baut eine Abfrage ihn neu). */
release(): void {
if (this.id) core().pick_index_release(this.id);
if (this.id && this.epoch === coreEpoch()) core().pick_index_release(this.id);
this.id = 0;
}