Skip to content

Fix requestAnimationFrame field naming, type, and handle lifecycle#1887

Merged
willeastcott merged 1 commit intomainfrom
fix/raf-field-naming
Mar 5, 2026
Merged

Fix requestAnimationFrame field naming, type, and handle lifecycle#1887
willeastcott merged 1 commit intomainfrom
fix/raf-field-naming

Conversation

@willeastcott
Copy link
Contributor

@willeastcott willeastcott commented Mar 5, 2026

Summary

  • Renames requestAnimationFrame handle fields that were misleadingly named with "timeout" to use a _raf prefix, accurately reflecting their use of requestAnimationFrame/cancelAnimationFrame rather than setTimeout/clearTimeout
  • Fixes incorrect type ReturnType<typeof setTimeout> to number for _rafClipNameChange in sprite.ts
  • Fixes RAF handle lifecycle: ensures handles are nulled after firing and properly cancelled+nulled in unlink() to prevent stale state and post-unlink work

Renames

File Old Name New Name
sprite.ts _timeoutAfterClipNameChange _rafClipNameChange
script.ts _dirtyScriptsTimeout _rafDirtyScripts
model.ts _timeoutRefreshMappings _rafRefreshMappings

Lifecycle fixes

  • sprite.ts: _onAfterClipNameChange now nulls _rafClipNameChange on entry (the RAF has already fired); unlink() now cancels+nulls the pending RAF
  • script.ts: unlink() now nulls _rafDirtyScripts after cancelling it (was cancel-only)
  • model.ts: Already had correct lifecycle handling (no changes)

@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
editor Ready Ready Preview, Comment Mar 5, 2026 10:42am

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR cleans up inspector component code by renaming misnamed requestAnimationFrame handle fields (previously labeled as “timeout”) and correcting an incorrect handle type in the sprite inspector to better reflect requestAnimationFrame/cancelAnimationFrame usage.

Changes:

  • Renamed RAF handle fields to use a _raf* prefix in sprite, script, and model component inspectors.
  • Corrected the sprite clip-name-change RAF handle type from ReturnType<typeof setTimeout> to number.
  • Updated corresponding cancelAnimationFrame/requestAnimationFrame call sites to use the renamed fields.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/editor/inspector/components/sprite.ts Renames clip-name-change scheduling handle and fixes its type to match RAF usage.
src/editor/inspector/components/script.ts Renames deferred “dirty scripts” RAF handle and updates cancellation/scheduling references.
src/editor/inspector/components/model.ts Renames mappings refresh RAF handle and updates cancellation/scheduling references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

…raf and fix handle lifecycle

Made-with: Cursor
@willeastcott willeastcott force-pushed the fix/raf-field-naming branch from 79948a7 to c2953b6 Compare March 5, 2026 10:42
@willeastcott willeastcott changed the title Fix requestAnimationFrame field naming and type Fix requestAnimationFrame field naming, type, and handle lifecycle Mar 5, 2026
@willeastcott willeastcott requested a review from Copilot March 5, 2026 10:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@willeastcott willeastcott merged commit 46f6eb8 into main Mar 5, 2026
11 checks passed
@willeastcott willeastcott deleted the fix/raf-field-naming branch March 5, 2026 10:49
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.

2 participants