fix(ios): re-attach root view after in-process runtime reload#11261
fix(ios): re-attach root view after in-process runtime reload#11261NathanWalker wants to merge 2 commits into
Conversation
When the runtime is reloaded in-process (NativeScriptRuntime.reloadApplication, used for OTA soft reboots) the app re-runs main in a fresh JS isolate while the process stays alive. iOSApplication.run() sees a live UIApplication and routes to runAsEmbeddedApp() - The previous UIWindow was deallocated along with the old isolate (it was retained only by the JS-side SceneDelegate._window), and sceneWillConnectToSession — which creates the window — does not re-fire on a reload. getWindow() then returned null and runAsEmbeddedApp() bailed early, leaving a black screen. - With no embedder delegate (NativeScript owns the UIApplication), the new root was presented modally over the old, now-dead root controller instead of replacing it — leaking the old controller on every reload and breaking when an overlay is mid-presentation. runAsEmbeddedApp() now: - recreates a window bound to the active UIWindowScene when none is found (initWithWindowScene + _setWindowForScene/_setupWindowForScene); - moves the rootViewController guard into the embedder-only branch, since a freshly recreated window has no controller yet; - replaces the window root via setWindowRootView() for the NativeScript-owned case instead of modal-presenting over the stale root.
|
View your CI Pipeline Execution ↗ for commit 51b957a
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place. 📝 WalkthroughWalkthroughThis PR updates embedded NativeScript app initialization to handle missing UIWindow by recreating it bound to an active UIWindowScene, tolerate null root view controller during startup, and adjust view attachment strategies based on embedder presence versus direct owning-app mode. ChangesEmbedded app window initialization
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Nathan Walker <[email protected]>
When the runtime is reloaded in-process (NativeScriptRuntime.reloadApplication, used for OTA soft reboots) the app re-runs main in a fresh JS isolate while the process stays alive. iOSApplication.run() sees a live UIApplication and routes to runAsEmbeddedApp()
runAsEmbeddedApp() works same as before but now supports this use case:
Supports 9.1 runtime features for OTA installed hot reloading of runtime isolates.