Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null check added to avoid NPE while calling FlutterView.detachFromFlutterEngine() #41082

Merged
merged 9 commits into from
Apr 17, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,13 @@ void onDestroyView() {
flutterView.getViewTreeObserver().removeOnPreDrawListener(activePreDrawListener);
activePreDrawListener = null;
}
flutterView.detachFromFlutterEngine();
flutterView.removeOnFirstFrameRenderedListener(flutterUiDisplayListener);

// flutterView can be null in instances where a delegate.onDestroyView is called without
// onCreateView being called. See https://github.com/flutter/engine/pull/41082 for more detail.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: in general the code should stand in isolation; there's no guarantee that the issue database will last as long as the code comments. so if there is more useful data to include it would be good to just describe it all here rather than linking to the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree which is why there is a description before the link. That said this link has way more information than I think could (should?) fit in a comment include screenshots and statements about androids observed behavior. All in if someone wanted to understand why how onDestroyView can be called without onCreateView then the link is the best place to learn more.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general if we think more documentation is needed, then I would recommend putting it in a README.md, or, at the extreme, in a wiki page. We shouldn't consider PR descriptions to be canonical documentation sources.

if (flutterView != null) {
bastionkid marked this conversation as resolved.
Show resolved Hide resolved
flutterView.detachFromFlutterEngine();
flutterView.removeOnFirstFrameRenderedListener(flutterUiDisplayListener);
}
}

void onSaveInstanceState(@Nullable Bundle bundle) {
Expand Down