flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.15k stars 27.47k forks source link

Crash in RenderObject.getTransformTo #148656

Open nikorehnback opened 5 months ago

nikorehnback commented 5 months ago

Steps to reproduce

Not sure how to reproduce the scenario. Got thousands of crashes reported into Crashlytics.

Expected results

Flutter framework shouldn't crash. Looking at the source code owner is force casted to non null:

final RenderObject? rootNode = owner!.rootNode;

Actual results

Flutter framework crashes with null pointer exception. Would be nice to understand if this is a bug in Flutter and if not, in which scenario this can happen.

Code sample

-

Screenshots or Video

No response

Logs

Logs ```console Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value. Error thrown . #00 pc 0x365b13 com.app.redacted (RenderObject.getTransformTo [object.dart:3337]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #01 pc 0x365bb3 com.app.redacted (RenderBox.localToGlobal [box.dart:2619]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #02 pc 0x3e4f23 com.app.redacted (_PlatformViewPlaceholderBox.performLayout. [platform_view.dart:1279]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #03 pc 0x9f0d3b com.app.redacted (SchedulerBinding._invokeFrameCallback [binding.dart:1386]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #04 pc 0x9f0b7f com.app.redacted (SchedulerBinding.handleDrawFrame [binding.dart:1322]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #05 pc 0x3a8997 com.app.redacted (SchedulerBinding._handleDrawFrame [binding.dart:1169]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #06 pc 0x3a884b com.app.redacted (SchedulerBinding._handleDrawFrame [binding.dart:1151]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #07 pc 0x325f63 com.app.redacted (_invoke [hooks.dart:312]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #08 pc 0x3280b7 com.app.redacted (PlatformDispatcher._drawFrame [platform_dispatcher.dart:399]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #09 pc 0x32806b com.app.redacted (_drawFrame [hooks.dart:283]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) #10 pc 0x3280e7 com.app.redacted (_drawFrame [hooks.dart:281]) (BuildId: b866ace1c9279fdbf7dae5b7041a6fbf) ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.19.5, on macOS 13.5 22G74 darwin-arm64, locale en-GB) • Flutter version 3.19.5 on channel stable at /Users/developer/Downloads/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 300451adae (8 weeks ago), 2024-03-27 21:54:07 -0500 • Engine revision e76c956498 • Dart version 3.3.3 • DevTools version 2.31.1 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc2) • Android SDK at /Users/developer/Library/Android/sdk • Platform android-34, build-tools 33.0.0-rc2 • ANDROID_HOME = /Users/developer/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C65 • CocoaPods version 1.14.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.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 • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) [✓] VS Code (version 1.86.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.82.0 [✓] Connected device (3 available) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator) • macOS (desktop) • macos • darwin-arm64 • macOS 13.5 22G74 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.208 [✓] Network resources • All expected network resources are available. • No issues found! ```
jonahwilliams commented 5 months ago

https://github.com/flutter/flutter/blob/414d9238720a3cde85475f49ce0ba313f95046f7/packages/flutter/lib/src/widgets/platform_view.dart#L1523-L1527

Not sure what happens if this placeholder gets unmounted before the postframe callback fires (or if that can happen). But I think that would result in the renderbox check failing.

darshankawar commented 5 months ago

Labeling for team's tracking.

goderbauer commented 5 months ago

Yeah, looks like the frame callback is missing a check for attached.

pamafe1976 commented 5 months ago

Getting several crash reports due to this error too. in my case, they are all happening in IOS.

wxjrkm520 commented 5 months ago

I am experiencing the same issue. It currently occurs at least with Lottie and ClipPath.

wxjrkm520 commented 5 months ago

they are all happening in IOS.

escamoteur commented 4 months ago

we see the same in 3.22 on Android devices

_TypeError: Null check operator used on a null value
  File "object.dart", line 3339, in RenderObject.getTransformTo
  File "box.dart", line 2886, in RenderBox.localToGlobal
  File "platform_view.dart", line 1526, in _PlatformViewPlaceholderBox.performLayout.<fn>
  File "binding.dart", line 1392, in SchedulerBinding._invokeFrameCallback
  File "binding.dart", line 1326, in SchedulerBinding.handleDrawFrame
  File "binding.dart", line 1171, in SchedulerBinding._handleDrawFrame
  File "zone.dart", line 1399, in _rootRun
  File "zone.dart", line 1301, in _CustomZone.run
  File "zone.dart", line 1209, in _CustomZone.runGuarded
  File "hooks.dart", line 314, in _invoke
  File "platform_dispatcher.dart", line 419, in PlatformDispatcher._drawFrame
  File "hooks.dart", line 283, in _drawFrame