Skip to content

[Google3 Bug]: Crashes coming from MediaQuery.maybeDevicePixelRatioOf #172289

@math1man

Description

@math1man

Help us understand the severity of this issue

  • causing severe production issues e.g. malfunctions or data loss
  • blocking next binary release
  • blocking a client feature launch within a quarter
  • nice-to-have but does not block a launch within the next quarter

Steps to reproduce

None, crashes observed in production at a significant rate.

Expected results

Does not crash

Actual results

Crashes:

_TypeError
at InheritedModel._findModels(inherited_model.dart:160)
at InheritedModel.inheritFrom(inherited_model.dart:200)
at MediaQuery._maybeOf(media_query.dart:1282)
at MediaQuery.maybeDevicePixelRatioOf(media_query.dart:1394)
at createLocalImageConfiguration(image.dart:68)
at DecoratedBox.createRenderObject(container.dart:87)
at RenderObjectElement.mount(framework.dart:6686)
at SingleChildRenderObjectElement.mount(framework.dart:7008)
at Element.inflateWidget(framework.dart:4540)
at ComponentElement.performRebuild(framework.dart:5739)
at StatefulElement.performRebuild(framework.dart:5875)
at BuildScope._tryRebuild(framework.dart:2695)
at BuildScope._flushDirtyElements(framework.dart:2753)
at BuildOwner.buildScope(framework.dart:3057)
at _LayoutBuilderElement._rebuildWithConstraints(layout_builder.dart:272)
at RenderAbstractLayoutBuilderMixin.layoutCallback(layout_builder.dart:335)
at RenderObjectWithLayoutCallbackMixin.runLayoutCallback.<anonymous closure>(object.dart:4160)
at RenderObject.invokeLayoutCallback.<anonymous closure>(object.dart:2885)
at PipelineOwner._enableMutationsToDirtySubtrees(object.dart:1209)
at RenderObject.invokeLayoutCallback(object.dart:2884)
at RenderObjectWithLayoutCallbackMixin.runLayoutCallback(object.dart:4160)
at _RenderLayoutBuilder.performLayout(layout_builder.dart:449)
at RenderObject.layout(object.dart:2766)
at RenderProxyBoxMixin.performLayout(proxy_box.dart:115)
at RenderObject.layout(object.dart:2766)
at RenderProxyBoxMixin.performLayout(proxy_box.dart:115)
at RenderObject.layout(object.dart:2766)
at RenderProxyBoxMixin.performLayout(proxy_box.dart:115)
at RenderObject.layout(object.dart:2766)
at ChildLayoutHelper.layoutChild(layout_helper.dart:62)
at ChildLayoutHelper.layoutChild(layout_helper.dart:61)
at RenderStack._computeSize(stack.dart:646)
at RenderStack.performLayout(stack.dart:673)
at RenderObject.layout(object.dart:2766)
at RenderProxyBoxMixin.performLayout(proxy_box.dart:115)
at RenderObject.layout(object.dart:2766)
at MultiChildLayoutDelegate.layoutChild(custom_layout.dart:180)
at _ScaffoldLayout.performLayout(scaffold.dart:1119)
at MultiChildLayoutDelegate._callPerformLayout(custom_layout.dart:249)
at RenderCustomMultiChildLayoutBox.performLayout(custom_layout.dart:419)
at RenderObject.layout(object.dart:2766)
at RenderProxyBoxMixin.performLayout(proxy_box.dart:115)
at RenderObject.layout(object.dart:2766)
at RenderProxyBoxMixin.performLayout(proxy_box.dart:115)
at _RenderCustomClip.performLayout(proxy_box.dart:1483)
at RenderObject.layout(object.dart:2766)
at ChildLayoutHelper.layoutChild(layout_helper.dart:62)
at ChildLayoutHelper.layoutChild(layout_helper.dart:61)
at RenderStack._computeSize(stack.dart:646)
at RenderStack.performLayout(stack.dart:673)
at RenderObject._layoutWithoutResize(object.dart:2614)
at PipelineOwner.flushLayout(object.dart:1160)
at PipelineOwner.flushLayout(object.dart:1173)
at RendererBinding.drawFrame(binding.dart:629)
at WidgetsBinding.drawFrame(binding.dart:1261)
at RendererBinding._handlePersistentFrameCallback(binding.dart:495)
at RendererBinding._handlePersistentFrameCallback(binding.dart:494)
at SchedulerBinding._invokeFrameCallback(binding.dart:1438)
at SchedulerBinding.handleDrawFrame(binding.dart:1351)
at SchedulerBinding._handleDrawFrame(binding.dart:1204)
at SchedulerBinding._handleDrawFrame(binding.dart:1186)
at _rootRun(zone.dart:1525)
at _rootRun(zone.dart:1516)
at _CustomZone.run(zone.dart:1422)
at _CustomZone.runGuarded(zone.dart:1321)
at _invoke(hooks.dart:333)
at PlatformDispatcher._drawFrame(platform_dispatcher.dart:444)
at _drawFrame(hooks.dart:303)
at _drawFrame(hooks.dart:301)

I believe the root cause is this line in InheritedModel:

final T modelWidget = model.widget as T;
The code assumes that model.widget is of type T, and for some reason that is failing. The issue could also be the call to model.widget, which under the hood has a null check on the actual field:
Widget get widget => _widget!;
.

Code sample

Code sample: None

Screenshots or Video

Screenshots / Video demonstration: none

Logs

Logs: none

Flutter Doctor output

Doctor output: N/A, google3 internal client

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolecustomer: googleVarious Google teamsframeworkflutter/packages/flutter repository. See also f: labels.needs repro infoAutomated crash report whose cause isn't yet knownteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions