Repository navigation
fix(runtime): ignore a stale error-report marker - #2124
Draft
edusperoni wants to merge 1 commit into
Draft
edusperoni wants to merge 1 commit into
edusperoni wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Draft
4 of 5 tasks
ErrorReport writes files/hasError before it starts ErrorReportActivity, and the next process start consumes it to skip runtime init so the error screen can show. When Android blocks the error activity's start (a crash during Application.onCreate on API 35 is a background activity launch), the marker survives, and the next normal launch skips runtime init and crashes. The marker now counts only when one of the app's tasks has ErrorReportActivity on top, i.e. the process is starting for it.
edusperoni
force-pushed
the
fix/stale-error-marker
branch
from
November 20, 2026 13:15
5256901 to
165aff2
Compare
This branch has not been deployed
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.
Description
Symptom. In a debug build, after a crash whose error screen never appeared, the next normal launch of the app crashes before any JavaScript runs:
Cannot initialize an instance of com.tns.NativeScriptActivity: no NativeScript runtime is bound to thread "main";ClassNotFoundException: com.tns.NativeScriptActivity(no JavaScript ran, so nothing registered it).The launch after that one works.
Root cause.
ErrorReport.startActivitywritesfiles/hasError(test-app/app/src/debug/java/com/tns/ErrorReport.java:144), sends the pending intent forErrorReportActivity(:147) and kills the process (:152).RuntimeHelper.hasErrorIntent(test-app/app/src/main/java/com/tns/RuntimeHelper.java:30-58), deletes it, andinitRuntimethen skips runtime initialization (:79-80). That way the error activity can show without re-running the failing code.Application.onCreatecounts as a background activity launch, and logcat showsBackground activity launch blocked! … ErrorReportActivity … (BAL_BLOCK).Fix. The marker still gets deleted on every start. It now counts only when one of the app's tasks has
com.tns.ErrorReportActivityon top (ActivityManager.getAppTasks(), withtopActivityon API 23+ andbaseIntent's component before that). AtApplication.onCreatetime, the activity the process is starting for is already the top of its task. If the tasks can't be read, the old behaviour stays.Does your commit message include the wording below to reference a specific issue in this repo?
No issue. It was found while bringing up the
@nativescript/vitedev boot on Android.Related Pull Requests
None.
Does your pull request have unit tests?
No. The decision depends on
ActivityManagerstate at process start, and theappmodule has no JVM test harness. Verified manually on an API 35 emulator (Pixel 9 Pro image) with@nativescript/android9.1.2-next.2026-11-18(this branch's base commit,a12106397). The test app had thisRuntimeHelper.javapatched into its generatedplatforms/androidproject and was rebuilt through the CLI.Stale marker:
RuntimeHelper:run-as <app> touch files/hasError, then a normalam startcrashed withClassNotFoundException: com.tns.NativeScriptActivity.Blocked error activity:
throwat the top of the app'sbundle.mjscrashedApplication.onCreate, and the system loggedBAL_BLOCKforErrorReportActivity.am startlaunched the app normally.Error activity still shows: with the app visible, a delayed
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(…)startedErrorReportActivity(BAL_ALLOW_VISIBLE_WINDOW). Its new process honored the marker, the error screen showed the exception, and the marker was consumed.