Repository navigation
Null check operator used on a null value in PlatformView. #96384
Description
Activity
- changed the title
[-]Null check operator used on a null value. [/-][+]Null check operator used on a null value in PlatformView. [/+]on Jan 10, 2022 - addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Jan 10, 2022 @rahul-bst
Can you provide yourflutter doctor -vand possibly a complete minimal reproducible code sample that would throw this exception ?- addedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jan 10, 2022 Hi,
The app is built with Github Action on random remote machine where we use flutter v2.2.1. We have crashlytics added where we got this issue reported.
flutter doctor of my machine doesn't matter much but here it goes:
[✓] Flutter (Channel unknown, 2.2.1, on macOS 11.6.2 20G314 darwin-x64, locale en-GB) • Flutter version 2.2.1 at /Users/rahul/Library/flutter/flutter221/flutter2 • Framework revision 02c026b03c (8 months ago), 2021-05-27 12:24:44 -0700 • Engine revision 0fdb562ac8 • Dart version 2.13.1 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc4) • Android SDK at /Users/rahul/Library/Android/sdk • Platform android-31, build-tools 31.0.0-rc4 • ANDROID_HOME = /Users/rahul/Library/Android/sdk • Java binary at: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java • Java version Java(TM) SE Runtime Environment (build 1.8.0_201-b09) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 13.0, Build version 13A233 • CocoaPods version 1.11.2 [!] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio. [✓] IntelliJ IDEA Community Edition (version 2021.2.3) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart [✓] VS Code (version 1.63.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.26.0 [✓] Connected device (1 available) • macOS (desktop) • macos • darwin-x64 • macOS 11.6.2 20G314 darwin-x64 ! Error: Rahul’s iPhone is not connected. Xcode will continue when Rahul’s iPhone is connected. (code -13) ! Doctor found issues in 1 category.I looked at the source code in master branch as well and it definitely has potential for the bug. By the time,
_onPlatformViewCreatedis called, the Widget might be disposed leading to above mentioned error.I don't have steps to reproduce it right now, but if the explanation is insufficient I can come up with set of steps to reproduce it.
Thanks for the reply.
Regards,
Rahul K- removedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jan 10, 2022 Thanks for the update. It could be a possibililty that the widget has gone away by the time you call setState?
You can check https://master-api.flutter.dev/flutter/widgets/State/mounted.html and confirm the widget is mounted for the first time but the main thing to confirm if the widget is still mounted after it goes past any async calls ?- addedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jan 11, 2022 @darshankawar
We have the coming up on Sentry/Crashlytics as well on Flutter 2.8.1 (stable).The problem is obvious by just static code analyzing.
PlatformView's created callbacks get called from here:
callback(viewId); This is an async function with an await in it. It's normal for an element to be in a different state before and after an
awaithappens and a mounted check is always required before calling setState after an await like this.The problem stems from the fact that this issues's crash line
https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/platform_view.dart#L898
expects this to only ever be called when not disposed (which it should not).Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.@darshankawar
Why did actions close this automatically?We've given a direct view in to the problem and how to fix it.
@Moncader
Since this issue haswaitinglabel and there wasn't any response from original author for 21 days, the bot automatically closed it.
But I am reopening this and labeling based on your findings.Reacted by Jason Parrott and Daniel Gomez- addeda: null-safetySupport for Dart's null safety featureSupport for Dart's null safety featureframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.a: productionIssues experienced in live production appsIssues experienced in live production appsand removedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter respondsin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Feb 1, 2022 - addeda: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Feb 2, 2022 - added a commit that references this issue
on Feb 8, 2023 - addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Feb 9, 2023 - added a commit that references this issue
on Feb 15, 2023 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Mar 3, 2023
flutter/packages/flutter/lib/src/widgets/platform_view.dart
Line 898 in 7fe3565
setState is called when
elementis null.Stacktrace received on crashlytics: