Skip to content

Memory leak and screen become black when using PlatformView  #24145

Closed
@Fengxiaojun47503

Description

@Fengxiaojun47503

Steps to Reproduce

  1. create a listview include platform view, for example ervery 5 item there is a AndroidView
  2. repeatedly scroll down and up the listview, so that the AndroidView will be new create and dispose repeatedly.

result: the screen will become black and nothing will be shown after several times of step2.
And in the log, StrictMode show warning of that surface never release.
Out of memory error log occured at the same time

Logs

2018-11-09 13:55:20.215 14249-14258/xxx E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    java.lang.Throwable: Explicit termination method 'release' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:180)
        at android.view.Surface.setNativeObjectLocked(Surface.java:511)
        at android.view.Surface.<init>(Surface.java:179)
        at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:30)
        at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:179)
        at io.flutter.plugin.platform.PlatformViewsController.onMethodCall(PlatformViewsController.java:118)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
        at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:323)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
2018-11-09 13:54:34.450 14249-14258/xxx E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    java.lang.Throwable: Explicit termination method 'release' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:180)
        at android.view.Surface.setNativeObjectLocked(Surface.java:511)
        at android.view.Surface.<init>(Surface.java:179)
        at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:30)
        at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:179)
        at io.flutter.plugin.platform.PlatformViewsController.onMethodCall(PlatformViewsController.java:118)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
        at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:323)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

2018-11-09 13:55:25.168 14249-14416/xxx W/Adreno-GSL: <sharedmem_gpumem_alloc_id:2372>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
2018-11-09 13:55:25.186 14249-14416/xxx E/Adreno-GSL: <gsl_memory_alloc_pure:2115>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2018-11-09 13:55:26.240 14249-14887/xxx W/Ads: Not retrying to fetch app settings
2018-11-09 13:55:29.344 14249-14416/xxx W/Adreno-GSL: <sharedmem_gpumem_alloc_id:2372>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
2018-11-09 13:55:29.351 14249-14416/xxx E/Adreno-GSL: <gsl_memory_alloc_pure:2115>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2018-11-09 13:55:29.370 14249-14416/xxx W/Adreno-GSL: <sharedmem_gpumem_alloc_id:2372>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
2018-11-09 13:55:29.376 14249-14416/xxx E/Adreno-GSL: <gsl_memory_alloc_pure:2115>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2018-11-09 13:55:29.395 14249-14416/xxx W/Adreno-GSL: <sharedmem_gpumem_alloc_id:2372>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
2018-11-09 13:55:29.401 14249-14416/xxx E/Adreno-GSL: <gsl_memory_alloc_pure:2115>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.

<!-- Finally, paste the output of running `flutter doctor -v` here. -->
[✓] Flutter (Channel dev, v0.10.2, on Linux, locale zh_CN.UTF-8)
    • Flutter version 0.10.2 at /home/xxx/software/flutter
    • Framework revision d8cbb80206 (2 weeks ago), 2018-10-26 01:30:21 -0400
    • Engine revision 6c2ade9fa2
    • Dart version 2.1.0-dev.8.0.flutter-bf26f760b1

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /home/xxx/software/Android/Sdk
    • Android NDK at /home/xxx/software/Android/Sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /home/xxx/software/Android/Sdk
    • Java binary at: /home/xxx/Downloads/android-studio-ide-181.5056338-linux/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] Android Studio (version 3.2)
    • Android Studio at /home/xxx/Downloads/android-studio-ide-181.5056338-linux/android-studio
    • Flutter plugin version 30.0.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected device (1 available)
    • Nexus 6 • ZX1G22LZ39 • android-arm • Android 7.1.1 (API 25)

• No issues found!

Metadata

Metadata

Assignees

Labels

a: platform-viewsEmbedding Android/iOS views in Flutter appsc: performanceRelates to speed or footprint issues (see "perf:" labels)customer: dream (g3)engineflutter/engine repository. See also e: labels.platform-androidAndroid applications specifically

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions