Skip to content

Add setRenderResetCallback alias for setDeviceLostCallback#1722

Merged
bghgary merged 2 commits into
BabylonJS:masterfrom
bghgary:rename-set-device-lost-callback
May 29, 2026
Merged

Add setRenderResetCallback alias for setDeviceLostCallback#1722
bghgary merged 2 commits into
BabylonJS:masterfrom
bghgary:rename-set-device-lost-callback

Conversation

@bghgary
Copy link
Copy Markdown
Contributor

@bghgary bghgary commented May 28, 2026

JS-exposed setDeviceLostCallback actually fires on device-restored (after bgfx::init on re-EnableRendering), not on loss. C++-internal SetRenderResetCallback is accurate; only the JS name was misleading.

Add setRenderResetCallback as the preferred name. Keep setDeviceLostCallback as 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]

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>
Copilot AI review requested due to automatic review settings May 28, 2026 20:23
Copy link
Copy Markdown
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

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 setRenderResetCallback as the preferred JS method name.
  • Retain setDeviceLostCallback as a deprecated alias with an explanatory comment.

@bghgary bghgary changed the title NativeEngine: add setRenderResetCallback alias for setDeviceLostCallback Add setRenderResetCallback alias for setDeviceLostCallback May 29, 2026
@bghgary bghgary enabled auto-merge (squash) May 29, 2026 17:43
@bghgary bghgary merged commit 06ddad0 into BabylonJS:master May 29, 2026
28 checks passed
@bghgary bghgary deleted the rename-set-device-lost-callback branch May 29, 2026 19:57
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