Skip to content

Conversation

@ryantrem
Copy link
Member

This PR implements Inspector._OpenedPane and Inspector._SetNewScene to make DebugLayer.openedPanes and DebugLayer.setAsActiveScene work.

The short term implementation for _SetNewScene is to just hide and reshow Inspector. This is because we already know we want to have multi-scene support, so we'll need to do more thinking about what _SetNewScene would mean in that context and whether there is something better than hiding/showing Inspector in this scenario.

However, doing this revealed some subtle timing bugs when hiding/showing Inspector back to back synchronously. Ultimately the problem is that React render/unmount both do hidden async work, and it must be sequentialized for everything to work correctly. So the biggest change in this PR is really just about managing all this internal asynchrony in a robust way that hides the complexity from the user. The new ShowInspector API still just synchronously returns a dispose token to keep things simple. Calling dispose on that token internally manages the async sequentialization. I like this because it makes the API simple, but I'm also not 100% sure hiding this asynchrony from the user will be the long term best solution, so I may still revisit the actual API before the 9.0 release (e.g. it may become async), but all the logic for managing the asynchrony (the hard part) should not need to change.

I'm creating this PR in draft as I will be OOF next week. If we don't want to leave it in draft for a week, we can also close it and re-open when I'm back.

Implement Inspector._SetNewScene

Make show/hide calls robust against React's hidden asynchrony
@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/17499/merge/

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17499/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17499/merge/?snapshot=refs/pull/17499/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 22, 2025

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