GeezerVison is showing github.com — feat: reloadApplication for JS bundle restart without restarting app process by NathanWalker · Pull Request #1963 · NativeScript/android
Conversation
NathanWalker
commented
Jun 7, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
NativeScriptRuntime.reloadApplication()
Helpful for programmatic reset of JS isolate for clean restart of JS application as well as OTA (over-the-air) updates without restarting the entire app process.
NativeScript/ios#384
Summary by CodeRabbit
- New Features
- Added a public runtime API for reloading the application, with optional base directory support.
- Bug Fixes
- Improved reload reliability and prevented duplicate reload scheduling.
- Improved runtime shutdown by terminating workers and safely recreating the main runtime.
- Fixed application state cleanup during reloads.
- Improved timezone listener handling to prevent duplicate registrations and stale listeners.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jun 7, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4b27b8af-034e-4b48-b8cd-2db73030b528
📥 Commits
Reviewing files that changed from the base of the PR and between e612f1b and 2bb05a8.
📒 Files selected for processing (5)
test-app/app/src/main/java/com/tns/NativeScriptRuntime.java
test-app/app/src/main/java/com/tns/RuntimeHelper.java
test-app/runtime/src/main/cpp/Runtime.cpp
test-app/runtime/src/main/cpp/com_tns_Runtime.cpp
test-app/runtime/src/main/java/com/tns/Runtime.java
🚧 Files skipped from review as they are similar to previous changes (3)
- test-app/app/src/main/java/com/tns/NativeScriptRuntime.java
- test-app/app/src/main/java/com/tns/RuntimeHelper.java
- test-app/runtime/src/main/java/com/tns/Runtime.java
📝 Walkthrough
Walkthrough
The PR adds public Java reload APIs, main-thread restart scheduling, Java and native runtime teardown, and main-runtime lifecycle reset handling. It also updates timezone receiver registration to use cached application context state.
Changes
Application reload and runtime teardown
| Layer / File(s) |
Summary |
Reload entry points test-app/app/src/main/java/com/tns/NativeScriptRuntime.java |
NativeScriptRuntime adds two static reloadApplication overloads and a private constructor. |
Reload scheduling and context state test-app/app/src/main/java/com/tns/RuntimeHelper.java |
RuntimeHelper caches application context, prevents duplicate scheduled reloads, reloads the runtime on the main thread, and tracks timezone receiver registration. |
Java runtime shutdown test-app/runtime/src/main/java/com/tns/Runtime.java |
Runtime adds destroyMainRuntime() and a native termination declaration. The method clears runtime state and invokes native termination. |
Native runtime teardown test-app/runtime/src/main/cpp/com_tns_Runtime.cpp, test-app/runtime/src/main/cpp/Runtime.cpp |
The JNI callback stops child workers, disposes the isolate, removes its event-loop entry, and deletes the runtime. Main-runtime destruction resets shared lifecycle state. |
Estimated code review effort: 4 (Complex) | ~45 minutes
Merge Risk: ⚪ Minimal · up to 2bb05
The PR adds programmatic JavaScript bundle restarts without restarting the app process, and no actionable merge-blocking risk remains; it is merge-ready after normal checks.
Sequence Diagram(s)
sequenceDiagram
participant NativeScriptRuntime
participant RuntimeHelper
participant Runtime
participant NativeTerminationCallback
participant V8Runtime
NativeScriptRuntime->>RuntimeHelper: reloadApplication()
RuntimeHelper->>Runtime: destroyMainRuntime()
Runtime->>NativeTerminationCallback: TerminateRuntimeCallback(runtimeId)
NativeTerminationCallback->>V8Runtime: terminate workers and destroy isolate
NativeTerminationCallback-->>Runtime: native termination completes
RuntimeHelper->>RuntimeHelper: initialize and run replacement runtime
Loading
Possibly related PRs
Suggested reviewers: edusperoni
Poem
🐰 I press reload and clear the way,
The old runtime hops away.
Workers rest, the isolate ends,
A fresh runtime soon ascends.
Context cached, the clock receiver stays.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 8.70% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title clearly summarizes the main change: adding reloadApplication to restart the JavaScript bundle without restarting the app process. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
- Create stacked PR
- Commit on current branch
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.
❤️ Share
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@copilot resolve the merge conflicts in this pull request
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.
Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/NativeScript/android/issues/comments/4644331376","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- review_stack_entry_start -->\n\n[](https://app.coderabbit.ai/change-stack/NativeScript/android/pull/1963?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)\n\n<!-- review_stack_entry_end -->\n<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->\n\n> [!NOTE]\n> Currently processing new changes in this PR. This may take a few minutes, please wait...\n> \n> <details>\n> <summary>⚙️ Run configuration</summary>\n> \n> **Configuration used**: Repository UI\n> \n> **Review profile**: CHILL\n> \n> **Plan**: Pro\n> \n> **Run ID**: `c0734d0e-2bd3-477e-bb92-e2612ac6c7a8`\n> \n> </details>\n> \n> <details>\n> <summary>📥 Commits</summary>\n> \n> Reviewing files that changed from the base of the PR and between bfd765043aaa30cc1ef14d00e3cebfa04e980597 and 187b183c718ddee1b3d3804dd7ddfd1ee6b8839d.\n> \n> </details>\n> \n> <details>\n> <summary>📒 Files selected for processing (4)</summary>\n> \n> * `test-app/app/src/main/java/com/tns/NativeScriptRuntime.java`\n> * `test-app/app/src/main/java/com/tns/RuntimeHelper.java`\n> * `test-app/runtime/src/main/cpp/com_tns_Runtime.cpp`\n> * `test-app/runtime/src/main/java/com/tns/Runtime.java`\n> \n> </details>\n> \n> ```ascii\n> ______________________________________________________________\n> < Ad Astra Per Codicem Fixis. To the stars through code fixes. >\n> --------------------------------------------------------------\n> \\\n> \\ (\\__/)\n> (•ㅅ•)\n> / づ\n> ```\n\n<!-- end of auto-generated comment: review in progress by coderabbit.ai -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>📝 Generate docstrings</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> Create stacked PR\n- [ ] <!-- {\"checkboxId\": \"3e1879ae-f29b-4d0d-8e06-d12b7ba33d98\"} --> Commit on current branch\n\n</details>\n<details open>\n<summary>⚔️ Resolve merge conflicts</summary>\n\n- [ ] <!-- {\"checkboxId\": \"c3a5b2e1-4d7f-4a8c-b9d6-e1f2c3d4a5b6\"} --> Resolve merge conflict in branch `feat/reload-app`\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=NativeScript/android&utm_content=1963)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":3,"signal":{},"retries":3,"retryAfter":16}}}
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
@copilot resolve the merge conflicts in this pull request
Resolved and pushed via merge commit 7b1f57c8 (merged origin/main into this branch and fixed both conflict files: Runtime.java and com_tns_Runtime.cpp).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test-app/app/src/main/java/com/tns/NativeScriptRuntime.java`:
- Around line 11-12: The NativeScriptRuntime.reloadApplication(String baseDir)
overload currently drops its baseDir argument, so callers cannot reload from a
chosen bundle location. Update this method to either pass baseDir through to a
new RuntimeHelper.reloadApplication(String baseDir) implementation that rebuilds
the runtime config from that directory, or remove the overload if it is not
meant to be supported; keep the API behavior aligned with the method signature
and related RuntimeHelper reload logic.
In `@test-app/app/src/main/java/com/tns/RuntimeHelper.java`:
- Around line 340-349: `registerTimezoneChangedListener` is unregistering
`timezoneChangedReceiver` with whatever `context` is passed in, but that can
differ between the initial call and `reloadApplication`, causing the old
receiver to remain registered. Update the listener bookkeeping so the same
Context instance used for registration is also used for `unregisterReceiver`
(for example by storing the registering Context alongside
`timezoneChangedReceiver` or consistently using `applicationContext` in
`registerTimezoneChangedListener` and its callers). Keep the existing
`IllegalArgumentException` handling only for truly stale registrations, and
ensure the old receiver is fully removed before assigning and registering the
new one.
In `@test-app/runtime/src/main/cpp/com_tns_Runtime.cpp`:
- Around line 358-362: The null-runtime checks in the affected callbacks do not
stop execution, so `runtime->GetIsolate()` can still be called on a null pointer
and crash. In each callback that resolves a `runtime` and then uses it
(`com_tns_Runtime` helpers around the reported branches), add an immediate
return inside the `if (runtime == nullptr)` path before any dereference, and
apply the same early-exit pattern consistently to all listed null-runtime
branches.
In `@test-app/runtime/src/main/java/com/tns/Runtime.java`:
- Around line 478-500: The termination flow in Runtime.destroyMainRuntime() and
terminateWorkers() is racing because the TerminateThread message is posted
asynchronously and workerIdToHandler is cleared immediately afterward. Add a
blocking handshake so terminateWorkers() waits until each worker has actually
processed the termination signal before destroyMainRuntime() continues with
runtimeCache.remove(), pendingWorkerMessages.clear(), currentRuntime.remove(),
and TerminateRuntimeCallback. Use the existing Runtime and workerHandler
messaging path to coordinate completion, and only clear workerIdToHandler after
all workers confirm shutdown.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e52793de-9a24-4365-9c36-5c412d5895b3
📥 Commits
Reviewing files that changed from the base of the PR and between 92c2654 and 7b1f57c.
📒 Files selected for processing (4)
test-app/app/src/main/java/com/tns/NativeScriptRuntime.java
test-app/app/src/main/java/com/tns/RuntimeHelper.java
test-app/runtime/src/main/cpp/com_tns_Runtime.cpp
test-app/runtime/src/main/java/com/tns/Runtime.java
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…process
Helpful for programmatic reset of JS isolate for clean restart of JS application as well as OTA (over-the-air) updates without restarting the entire app process.
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|