Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions packages/core/ui/frame/frame-helper-for-android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,33 @@ 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.
if (Trace.isEnabled()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NathanWalker We can't ignore the possibility that it may also occur if something goes wrong.
If it occurs too frequently in your apps, it's a sign there's something we shall take care of.
I'd suggest we removed the isEnabled check and use messageType.error instead to let message be printed no matter what.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work as well, will adjust 👍 (main thing is to avoid the trace.error there)

Trace.write(`${fragment}.onCreateView: entry is null or undefined`, Trace.categories.NativeLifecycle, Trace.messageType.warn);
}

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.
if (Trace.isEnabled()) {
Trace.write(`${fragment}.onCreateView: entry has no resolvedPage`, Trace.categories.NativeLifecycle, Trace.messageType.warn);
}

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.
if (Trace.isEnabled()) {
Trace.write(`${fragment}.onCreateView: this.frame is null or undefined`, Trace.categories.NativeLifecycle, Trace.messageType.warn);
}

return null;
}
Expand Down
Loading