Skip to content

fix(importer): release template claims after load failures - #301

Open
Ram-Dawson wants to merge 1 commit into
bdero:masterfrom
Ram-Dawson:fix/load-scene-template-claim-leak
Open

fix(importer): release template claims after load failures#301
Ram-Dawson wants to merge 1 commit into
bdero:masterfrom
Ram-Dawson:fix/load-scene-template-claim-leak

Conversation

@Ram-Dawson

@Ram-Dawson Ram-Dawson commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #300

Problem

loadScene() increments the shared template holder count before awaiting and realizing a scene. Previously, cleanup covered only template-load failures. If a custom component codec, node realization, stage application, or reload registration threw after the template was available, the caller received no Node to pair with releaseScene(), while its holder claim remained cached.

Change

Keep the early holder increment as a provisional claim so concurrent loads continue to protect a shared pending template. Extend the try/catch to cover template loading, realization, optional stage application, and hot-reload registration. On failure, release exactly one claim through a private helper. releaseScene() uses the same helper, so normal release and failure cleanup share the same decrement-and-evict behavior.

Validation

  • From packages/flutter_scene: flutter test (1129 passed, 31 skipped).
  • From packages/flutter_scene: flutter test test/fscene/scene_registry_test.dart (13 passed).
  • The new throwing-codec regression was verified red and green: the old implementation failed its post-error release assertion with Expected: false and Actual: true; the fixed implementation passes and leaves zero cached templates.
  • The new deferred-bundle test verifies that releasing one claim while another caller is waiting on the shared template does not evict it early; the final release evicts it.
  • From packages/flutter_scene: flutter analyze completed with no issues.

Scope and limitation

This fixes template claim accounting; it does not add per-request cancellation to loadScene(). releaseScene(path) remains key-based rather than a cancellation API for one particular in-flight request.

- Release the provisional holder claim when template loading, realization, stage setup, or reload registration fails.
- Cover throwing codecs and concurrent pending loads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SceneRegistry retains a scene template claim after realization failure

1 participant