Repository navigation
PopupMenuRoute crashes sometimes on drawFrame #163477
Copy link
Copy link
Closed
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolecustomer: googleVarious Google teamsVarious Google teamscustomer: money (g3)needs repro infoAutomated crash report whose cause isn't yet knownAutomated crash report whose cause isn't yet knownr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Steps to reproduce
- Add PopUpMenuButton and show it
- While the menu is being displayed, trigger drawFrame (such that PopupMenuRoute gets rebuilt)
- _positionBuilder inside PopupMenuRoute crashes due to the stale context
This crash only happens with this commit efa7d52. Seems like positionBuilder now calculates position dynamically, but it holds to the invalidated context sometimes.
Crash trace
_TypeError: Null check operator used on a null value
at Navigator.of (navigator.dart:2894)
at PopupMenuButtonState._positionBuilder (popup_menu.dart:1522)
at _PopupMenuRoute.buildPage.<anonymous closure> (popup_menu.dart:972)
at _LayoutBuilderElement._rebuildWithConstraints.updateChildCallback (layout_builder.dart:201)
at BuildOwner.buildScope (framework.dart:3056)
at _LayoutBuilderElement._rebuildWithConstraints (layout_builder.dart:240)
at _LayoutBuilderElement._rebuildWithConstraints (layout_builder.dart:196)
at RenderObject.invokeLayoutCallback.<anonymous closure> (object.dart:2827)
at PipelineOwner._enableMutationsToDirtySubtrees (object.dart:1161)
at RenderObject.invokeLayoutCallback (object.dart:2826)
at RenderConstrainedLayoutBuilder.rebuildIfNecessary (layout_builder.dart:293)
at _RenderLayoutBuilder.performLayout (layout_builder.dart:390)
at RenderObject.layout (object.dart:2715)
at RenderProxyBoxMixin.performLayout (proxy_box.dart:115)
at RenderObject.layout (object.dart:2715)
at RenderProxyBoxMixin.performLayout (proxy_box.dart:115)
at RenderObject.layout (object.dart:2715)
at RenderProxyBoxMixin.performLayout (proxy_box.dart:115)
at RenderObject.layout (object.dart:2715)
at RenderProxyBoxMixin.performLayout (proxy_box.dart:115)
at RenderObject.layout (object.dart:2715)
at RenderProxyBoxMixin.performLayout (proxy_box.dart:115)
at RenderOffstage.performLayout (proxy_box.dart:3750)
at RenderObject.layout (object.dart:2715)
at RenderProxyBoxMixin.performLayout (proxy_box.dart:115)
at RenderObject.layout (object.dart:2715)
at _RenderTheaterMixin.layoutChild (overlay.dart:1076)
at _RenderTheater.performLayout (overlay.dart:1422)
at RenderObject._layoutWithoutResize (object.dart:2548)
at PipelineOwner.flushLayout (object.dart:1112)
at PipelineOwner.flushLayout (object.dart:1125)
at RendererBinding.drawFrame (binding.dart:616)
at WidgetsBinding.drawFrame (binding.dart:1231)
at RendererBinding._handlePersistentFrameCallback (binding.dart:482)
at RendererBinding._handlePersistentFrameCallback (binding.dart:481)
at SchedulerBinding._invokeFrameCallback (binding.dart:1442)
at SchedulerBinding.handleDrawFrame (binding.dart:1355)
at SchedulerBinding._handleDrawFrame (binding.dart:1208)
at SchedulerBinding._handleDrawFrame (binding.dart:1190)
at _invoke (hooks.dart:316)
at PlatformDispatcher._drawFrame (platform_dispatcher.dart:428)
at _drawFrame (hooks.dart:288)
at _drawFrame (hooks.dart:286)
Expected results
Popup menu stays displayed
Actual results
App Crashes
Code sample
<>
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
✓] Flutter (Channel google3, on Debian GNU/Linux rodete 6.10.11-1rodete2-amd64, locale en_US.UTF-8) [93ms]
• Framework revision 5944d992ac (11 days ago), 2025-02-06T00:00:00.000
• Engine revision 5944d992ac
• Dart version 548dcc7a54
[✓] Android toolchain - develop for Android devices (Android SDK version Stable) [93ms]
• Android SDK at google3
• Platform Stable, build-tools Stable
• Java binary at: /opt/android-studio-with-blaze-stable/jbr/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
[!] Flutter IDE Support (No supported IDEs installed) [0ms]
• IntelliJ - https://www.jetbrains.com/idea/
• Android Studio - https://developer.android.com/studio/
• VS Code - https://code.visualstudio.com/
[✓] Connected device (1 available) [22ms]
• Linux (desktop) • linux • linux-x64 • Debian GNU/Linux rodete 6.10.11-1rodete2-amd64
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolecustomer: googleVarious Google teamsVarious Google teamscustomer: money (g3)needs repro infoAutomated crash report whose cause isn't yet knownAutomated crash report whose cause isn't yet knownr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Activity
yuwen-yan commentedon Feb 18, 2025
@YeungKC it seems you touched the related code recently in efa7d52, can you help take a look regarding the potential root cause or any additional null check we can perform in the code to be on the safer side.
YeungKC commentedon Feb 18, 2025
I've already made an attempt, but I couldn't reproduce the success. Could you provide me with a minimal reproducible example?
matanlurey commentedon Feb 18, 2025
@ChristianEdwardPadilla @bharathmg12 This issue needs a minimal reproducible sample as mentioned in the bug template:
yuwen-yan commentedon Feb 19, 2025
@YeungKC thanks for following on it! is it possible to add some null checks in the code (according to the crash stack trace in #163477 (comment) ) to make the code more robust to give it a try?
@matanlurey I understand that it's important to have a mini-reproducible sample for the investigation, not sure whether @bharathmg12 can help on it, I personally tried the following code, unfortunately, it can't reproduce it. let me know anything else we can do to help the investigation.
YeungKC commentedon Feb 19, 2025
I think we could add some null checks, but the problem is that I can't write tests...
cc @dkwingsmt
dkwingsmt commentedon Feb 19, 2025
@YeungKC Do you think it's possible to write test so that you just pump the test and do the gesture, and if it doesn't crash the test passes? (i.e. It doesn't have to have an
expectto be a test.)YeungKC commentedon Feb 19, 2025
@dkwingsmt Yes, I also hope to write a test that can crash 100% of the time to help me fix the bug, However, it seems that none of us can reproduce it at the moment.
Add null check should most likely fix the crash issue, but it doesn't sure that the position will be the expected position.
dkwingsmt commentedon Feb 19, 2025
Yeah we need a reliable reproduction to start fixing this issue.
@bharathmg12 Can you try to find more reliable reproductions of this error?
github-actions commentedon Mar 11, 2025
yuwen-yan commentedon Mar 13, 2025
@dkwingsmt is it possible to reopen this issue (I have no permission)? this crash is still happening in our app:/
@bharathmg12 gentle ping, let us know whether you can reproduce it, thanks in advance!
@YeungKC If we don't feel confident to fix the crash directly, is it possible perform additional check and throw a different exception to help us understand the crash first?
24 remaining items
Fix PopupMenuButton crashes when being hidden immediately (flutter#17…
math1man commentedon Jul 30, 2025
My app is also facing this issue (internal b/434889540, client
huggsy). I'll see if the fix addresses the crashes in our next release.math1man commentedon Aug 11, 2025
We haven't seen any reports from our latest app release that includes #166412.
math1man commentedon Aug 11, 2025
Worth noting that that release does not include #171970
yuwen-yan commentedon Aug 15, 2025
@huycozy thank you! it's working in our app.
huycozy commentedon Aug 18, 2025
Thank you all for confirming and re-testing this!
@dkwingsmt: Can we safely close this issue since @yuwen-yan confirmed above, or should we wait for @bharathmg12 to confirm as well?
dmitry-fbm commentedon Aug 18, 2025
@huycozy was it released in 3.35.1?
huycozy commentedon Aug 18, 2025
@dmitry-fbm Not yet as I can see: db38e71. However, it's on beta 3.36.0-0.1.pre already.
Fix PopupMenuButton crashes when being hidden immediately (flutter#17…
dkwingsmt commentedon Aug 19, 2025
Since a lot of people have confirmed the fix, I'm closing this issue. Feel free to reopen this issue or open a new one if found otherwise.
Thank you everyone for either working on it, reporting the bug, trying to reproduce it, and providing inspirations!
github-actions commentedon Sep 3, 2025
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.fix PopupMenuButton unmounted exception when updating position (flutt…