FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(android): don't crash in Fragment.onCreateView on stale-fragment race by NathanWalker · Pull Request #11264 · NativeScript/NativeScript · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 12 additions & 3 deletions packages/core/ui/frame/frame-helper-for-android.ts
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,30 @@ export class FragmentCallbacksImplementation implements AndroidFragmentCallbacks

const entry = this.entry;
if (!entry) {
Trace.error(`${fragment}.onCreateView: entry is null or undefined`);
// Recoverable race: a stale fragment is being driven to onCreateView by the
// FragmentManager after its entry was cleared.
// Using Trace.error (routes to an error handler, which throws) would be fatal as the error handler rethrows across the JNI boundary.
// Trace.write(..., Trace.messageType.error) logs without routing through that throwing path.
Trace.write(`${fragment}.onCreateView: entry is null or undefined`, Trace.categories.NativeLifecycle, Trace.messageType.error);

return null;
}

const page = entry.resolvedPage;
if (!page) {
Trace.error(`${fragment}.onCreateView: entry has no resolvedPage`);
// Logging via Trace.error (routes to an error handler, which throws) here is fatal because the registered error handler rethrows across the JNI boundary.
// Trace.write(..., Trace.messageType.error) keeps this recoverable path non-fatal.
Trace.write(`${fragment}.onCreateView: entry has no resolvedPage`, Trace.categories.NativeLifecycle, Trace.messageType.error);

return null;
}

const frame = this.frame;
if (!frame) {
Trace.error(`${fragment}.onCreateView: this.frame is null or undefined`);
// Recoverable race: the owning frame was already torn down. Returning null discards
// this fragment; using Trace.error (routes to an error handler, which throws) would be fatal as the error handler rethrows across the JNI boundary.
// Trace.write(..., Trace.messageType.error) logs without invoking the throwing error handler.
Trace.write(`${fragment}.onCreateView: this.frame is null or undefined`, Trace.categories.NativeLifecycle, Trace.messageType.error);

return null;
}
Expand Down

Back | FazBrowse Home | New Git URL