Skip to content

Android:FlutterView.getBitmap will crash after call it multiple times for a FlutterView in short time. #16750

@kangwang1988

Description

@kangwang1988

Steps to Reproduce

In our application, we have only one flutter context(one FlutterView wrapped in multiple FlutterWrapperActivity), so the getBitmap will be called when I want to push/pop when switching activities.

However, in our test, we noticed that getBitmap will cause an abort will be triggered when I call the getBitmap for the FlutterView(which is singleton). The original abort code is given below:

  const SkISize& frame_size = layer_tree->frame_size();
  jsize pixels_size = frame_size.width() * frame_size.height();
  jintArray pixels_array = env->NewIntArray(pixels_size);
  FXL_CHECK(pixels_array);

It's located in platform_view_android.cc.
And the crash message is:
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android.cc(717)] Check failed: pixels_array.

From my point of view, I should call the FlutterView.getBitmap with a lock to avoid the reentry(as I have only one FlutterView). Or should the
void PlatformViewAndroid::GetBitmapGpuTask
avoid aborting when this situation happens.

Flutter Doctor

[✓] Flutter (Channel beta, v0.1.6-pre.39, on Mac OS X 10.13.4 17E199, locale en-CN)
• Flutter version 0.1.6-pre.39 at /Users/kylewong/Codes/fwn_idlefish/flutter
• Framework revision 5cac396777 (2 days ago), 2018-04-17 13:09:18 +0800
• Engine revision e61bb9a
• Dart version 2.0.0-dev.35.flutter-290c576264

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/kylewong/Library/Android/sdk
• Android NDK at /Users/kylewong/Library/Android/sdk/ndk-bundle
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.3, Build version 9E145
• ios-deploy 1.9.2
• CocoaPods version 1.2.0

[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Connected devices (1 available)
• KyleWong's iPhone • 1c8e085cf2ff6fa27643ab4afec4bf4a077688af • ios • iOS 11.3

• No issues found!

Question:
How can I avoid the abort logic? Should I ensure that it's not reenterable or should the framework ensure that even I call it continously, it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions