Skip to content

fix(asset): add handle pin API to protect live assets from eviction - #365

Merged
Excurs1ons merged 1 commit into
masterfrom
fix/assets-eviction-pin
Oct 27, 2026
Merged

Excurs1ons merged 1 commit into
masterfrom
fix/assets-eviction-pin

Conversation

@Excurs1ons

Copy link
Copy Markdown
Owner

🤖 Generated by Antigravity (Google DeepMind)

Summary

Add an explicit pin/unpin/is_pinned API to ResourceManager (Option A from #172) while preserving Handle<T>: Copy. Automatic memory budget eviction (LRU and FIFO) filters out pinned slots from eviction candidates, preventing live handles from being discarded and failing with NotLoaded.

  • Added pin_count: u32 to internal Slot.
  • In ResourceManager::evict, filter candidates to only slots where pin_count == 0.
  • Added pin, unpin, is_pinned, pin_count for typed Handle<T>, type-erased AnyHandle, and AssetId.
  • Added error handling with RuntimeError::PinUnderflow if unpin is called with count 0.
  • unload, unload_id, and unload_all reset pin_count to 0.
  • Added comprehensive unit tests in runtime::tests covering eviction skipping pinned slots, out-of-memory when all candidate assets are pinned, eviction succeeding once unpinned, generation mismatch checks, and unload resets.

Fixes #172

Self-check (scripts/pr_ready.py)

  • mode: full · base: origin/master · HEAD: 6880a5f · changed: 2 file(s)
  • crates: prism-asset
Check Result Detail
whitespace / conflict markers ✅ clean
artifact / secret guard ✅ 2 file(s) checked
format (changed .rs) ✅ 2 file(s)
clippy (1 crate) ✅ -D warnings
test (1 crate) ✅ 102 passed
shader bindings drift ⏭️ no shader changes
editor fixture drift ⏭️ schema untouched
editor build ⏭️ editor untouched

Result: ✅ all checks passed

Introduce pin/unpin/is_pinned API on ResourceManager to prevent automatic eviction from discarding assets referenced by active callers while keeping Handle<T>: Copy.

Fixes #172
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-27T17:21:29.677303Z
We couldn’t complete this review. Comment @codex review to try again.
6880a5f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added area/assets asset / cooker / build-pipeline size/m 改动 100–499 行 labels Oct 27, 2026
@Excurs1ons
Excurs1ons merged commit f033561 into master Oct 27, 2026
6 checks passed
@Excurs1ons
Excurs1ons deleted the fix/assets-eviction-pin branch October 27, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/assets asset / cooker / build-pipeline size/m 改动 100–499 行

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(assets): eviction can discard data still referenced by a live Handle

1 participant