Skip to content

Fix resource reloading in editor#8455

Open
4ian wants to merge 11 commits intomasterfrom
fix/resources-reloading
Open

Fix resource reloading in editor#8455
4ian wants to merge 11 commits intomasterfrom
fix/resources-reloading

Conversation

@4ian
Copy link
Copy Markdown
Owner

@4ian 4ian commented Mar 30, 2026

Tests:

  • Local (Electron) app:
    • Cloud project, 2D editor:
      • Can modify an image with Piskel and see the modified image (for a Sprite)
      • Can modify an image with Piskel and see the modified image (for a Bitmap Font)
      • Can modify a file of a resource and see the modified image (Sprite/Bitmap Font)
      • Can set a wrong file for a resource and see the invalid texture (Sprite/Bitmap Font)
    • Cloud project, 3D editor:
      • Can modify an image with Piskel and see the modified image (for a Sprite)
      • Can modify an image with Piskel and see the modified image (for a Bitmap Font)
      • Can modify a file of a resource and see the modified image (Sprite/Bitmap Font)
      • Can set a wrong file for a resource and see the invalid texture (Sprite/Bitmap Font)
    • Local project, 2D editor:
      • Can modify an image on the file system and see the modified image (for a Sprite)
      • Can modify an image on the file system and see the modified image (for a Bitmap Font)
      • Can modify an image with Piskel and see the modified image (for a Sprite)
      • Can modify an image with Piskel and see the modified image (for a Bitmap Font)
      • Can modify a file of a resource and see the modified image (Sprite/Bitmap Font)
      • Can set a wrong file for a resource and see the invalid texture (Sprite/Bitmap Font)
    • Local project, 3D editor:
      • Can modify an image on the file system and see the modified image (for a Sprite)
      • Can modify an image on the file system and see the modified image (for a Bitmap Font)
      • Can modify an image with Piskel and see the modified image (for a Sprite)
      • Can modify an image with Piskel and see the modified image (for a Bitmap Font)
      • Can modify a file of a resource and see the modified image (Sprite/Bitmap Font)
      • Can set a wrong file for a resource and see the invalid texture (Sprite/Bitmap Font)
  • Web app:
    • Cloud project, 2D editor:
      • Can modify an image with Piskel and see the modified image (for a Sprite)
      • Can modify an image with Piskel and see the modified image (for a Bitmap Font)
      • Can modify a file of a resource and see the modified image (Sprite/Bitmap Font)
      • Can set a wrong file for a resource and see the invalid texture (Sprite/Bitmap Font)
    • Cloud project, 3D editor:
      • Can modify an image with Piskel and see the modified image (for a Sprite)
      • Can modify an image with Piskel and see the modified image (for a Bitmap Font)
      • Can modify a file of a resource and see the modified image (Sprite/Bitmap Font)
      • Can set a wrong file for a resource and see the invalid texture (Sprite/Bitmap Font)

Custom object tests:

  • (Local app) Custom object with a bitmap text, after the bitmap font atlas is modified on disk:
    • Rendering ok in custom object editor
    • Rendering ok in scene using the custom object
    • Rendering ok in custom object editor (3D editor)
    • Rendering ok in scene using the custom object (3D editor)

Multiple scene tests:

  • (Local or web app) when 2 scene (with 2D editors) are opened:
    • No crash when adding a new sprite from the asset store or bitmap text

Multiple resources pointing to the same file:

  • (Local or web app) loading should work when a resource is changed to be the same file as another:
    • Sprite
  • (Local or web app) no crash when two resources pointed to the same file as one is set to an invalid file

Basically, have to be robust against:

  • N resources pointing to the same file (both for reload and for unload).
  • Multiple objects using the same resource.
  • Multiple scene editor launched at the same time.

and we have to trigger reloads on:

  • File change for a resource (ResourcesEditor)
  • External editor used (xxxExternalEditor)
  • (local app only) file changed on file system (ResourceWatcher)

4ian and others added 7 commits March 29, 2026 17:43
When 2+ SceneEditors are open, a resource change notification is sent to
all editors, each calling reloadResource for the same resource. The second
reload would unload the texture just freshly loaded by the first, destroying
textures that active renderers in the first editor were already using. This
caused "invalid texture" errors for BitmapFonts and null texture crashes for
Sprites.

Deduplicate per-resource reload requests: if a reload for the same resource
is already pending, await the existing promise instead of queuing a new one.

https://claude.ai/code/session_016DxEMZRcWFM8jZZhNuEBYV
@4ian 4ian changed the title Fix/resources reloading Fix resource reloading in editor Mar 30, 2026
@@ -1851,17 +1849,17 @@ const MainFrame = (props: Props): React.MixedElement => {
() => {
if (isEditorHotReloadNeeded()) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

We might always reload project data here?

@@ -1851,17 +1849,17 @@ const MainFrame = (props: Props): React.MixedElement => {
() => {
if (isEditorHotReloadNeeded()) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this if seems useless now, and the method above does roughly the same (except different reason)

@4ian 4ian force-pushed the fix/resources-reloading branch from d211ce6 to 3a0835f Compare March 30, 2026 20:04
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.

3 participants