Add setRenderResetCallback alias for setDeviceLostCallback#1722
Merged
bghgary merged 2 commits intoMay 29, 2026
Conversation
The JS-exposed `setDeviceLostCallback` method actually fires on the device-RESTORED edge (after `bgfx::init` succeeds on a second-or-later `EnableRendering`, post-`DisableRendering`/`UpdateDevice` cycle), not on device loss. The C++-internal name `SetRenderResetCallback` is accurate; only the JS-facing string was misleading. Add `setRenderResetCallback` as the preferred name. Keep `setDeviceLostCallback` registered as an alias so existing Babylon.js builds (which call the legacy name) continue to work unchanged. Babylon.js guards the wiring with `if (this._engine.setDeviceLostCallback)`, so even if the alias were dropped, the only effect would be silent loss of device-restore notification -- no crash -- but keeping the alias preserves full functionality for older BJS. A follow-up Babylon.js PR can switch the call site from `setDeviceLostCallback` to `setRenderResetCallback`; the alias here can be removed in a later deprecation cycle. [Created by Copilot on behalf of @bghgary] Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new JS-facing method name setRenderResetCallback on NativeEngine that points at the existing SetRenderResetCallback implementation, while keeping the misleadingly-named setDeviceLostCallback as a backward-compatible alias.
Changes:
- Register
setRenderResetCallbackas the preferred JS method name. - Retain
setDeviceLostCallbackas a deprecated alias with an explanatory comment.
ryantrem
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JS-exposed
setDeviceLostCallbackactually fires on device-restored (afterbgfx::initon re-EnableRendering), not on loss. C++-internalSetRenderResetCallbackis accurate; only the JS name was misleading.Add
setRenderResetCallbackas the preferred name. KeepsetDeviceLostCallbackas a deprecated alias so existing BJS works unchanged. BJS #18518 switches to the new name with a fallback.[Created by Copilot on behalf of @bghgary]