Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

after hot restart serveral time while debuging will cause crash #14

Open
ManInTheWind opened this issue Jun 7, 2022 · 4 comments
Open

Comments

@ManInTheWind
Copy link

Describe the bug
after hot restart serveral time while debuging will cause crash,I have encountered this issue for many time.
sometimes the log show out of memory,but this time show like as below

* thread #42, queue = 'com.hackemist.SDImageCache', stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=2098 MB, unused=0x0)
    frame #0: 0x00000001a2dafde4 vImage`vConvert_16Q12to16F_vec + 208
vImage`vConvert_16Q12to16F_vec:
->  0x1a2dafde4 <+208>: stp    q4, q3, [x16]
    0x1a2dafde8 <+212>: ldp    q3, q2, [x1, #0x20]
    0x1a2dafdec <+216>: sshll.4s v4, v3, #0x0
    0x1a2dafdf0 <+220>: scvtf.4s v4, v4
Target 0: (Runner) stopped.
Lost connection to device.

To Reproduce
Steps to reproduce the behavior:
configured like the test demo and have replace most of image widget with power_image;

void main() async {
  runZonedGuarded(
    () async {
      PowerImageBinding();
      ...
      PowerImageLoader.instance.setup(
        PowerImageSetupOptions(
          renderingTypeTexture,
          errorCallbackSamplingRate: null,
          errorCallback: (PowerImageLoadException exception) {
            LogUtils.error(
              'Caught PowerImageLoadException : $exception',
            );
          },
        ),
      );
      runApp(const MyApp());
    },
    (Object error, StackTrace stackTrace) async {
     ...
    },
  );
}

Expected behavior
please dont crash that often 😅,

Screenshots
If applicable, add screenshots to help explain your problem.
image

Versions (please complete the following information):

  • Device: iPhone11
  • OS: ios15.3
  • flutter doctor -v:
展开查看 flutter doctor details

[✓] Flutter (Channel stable, 2.10.5, on macOS 12.4 21F79 darwin-x64, locale
    zh-Hans-CN)
    • Flutter version 2.10.5 at /Users/kangkang/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (7 weeks ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /Users/kangkang/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
• 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
11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.67.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.42.0

[✓] Connected device (2 available)
• iPhone 11 (mobile) • 00008030-00010D3826E0802E • ios • iOS 15.3
19D50
• Chrome (web) • chrome • web-javascript • Google
Chrome 102.0.5005.61

[!] HTTP Host Availability
✗ HTTP host https://maven.google.com/ is not reachable. Reason: An error occurred while
checking the HTTP host: Operation timed out

! Doctor found issues in 1 category.

  • power_image Version: ^0.1.0-pre.2
  • power_image_ext Version: ^3.0.0

Additional context

@wongkoo
Copy link
Collaborator

wongkoo commented Jun 7, 2022

It seems that the native cannot release the image memory due to hot restart, so the memory continues to increase, which eventually leads to OOM.

This problem only occurs when the renderingType is texture. Normally, when imageCache removes imageProvider, PowerImage will notify native to release memory. But when hot restart these processes are gone.

I'm guessing something similar to this issue:
flutter/flutter#10437
flutter/flutter#69949

@ManInTheWind
Copy link
Author

ManInTheWind commented Jun 7, 2022

It seems that the native cannot release the image memory due to hot restart, so the memory continues to increase, which eventually leads to OOM.

This problem only occurs when the renderingType is texture. Normally, when imageCache removes imageProvider, PowerImage will notify native to release memory. But when hot restart these processes are gone.

I'm guessing something similar to this issue: flutter/flutter#10437 flutter/flutter#69949

thanks for your reply,dose it will be work if execute clean image cache every time at the begin of run my app. like this

...
      PowerImageBinding();

      WidgetsFlutterBinding.ensureInitialized();

      if(kDebugMode){
         ///cleanCacheFirst

      }
...

@wongkoo
Copy link
Collaborator

wongkoo commented Jun 8, 2022

It seems that the native cannot release the image memory due to hot restart, so the memory continues to increase, which eventually leads to OOM.
This problem only occurs when the renderingType is texture. Normally, when imageCache removes imageProvider, PowerImage will notify native to release memory. But when hot restart these processes are gone.
I'm guessing something similar to this issue: flutter/flutter#10437 flutter/flutter#69949

thanks for your reply,dose it will be work if execute clean image cache every time at the begin of run my app. like this

...
      PowerImageBinding();

      WidgetsFlutterBinding.ensureInitialized();

      if(kDebugMode){
         ///cleanCacheFirst

      }
...

This should be useless. At this time, the hot restart has ended, and the ImageCache must be empty. The problem is that native doesn't perceive hot restart, so it never releases textures.

@ManInTheWind
Copy link
Author

It seems that the native cannot release the image memory due to hot restart, so the memory continues to increase, which eventually leads to OOM.
This problem only occurs when the renderingType is texture. Normally, when imageCache removes imageProvider, PowerImage will notify native to release memory. But when hot restart these processes are gone.
I'm guessing something similar to this issue: flutter/flutter#10437 flutter/flutter#69949

thanks for your reply,dose it will be work if execute clean image cache every time at the begin of run my app. like this

...
      PowerImageBinding();

      WidgetsFlutterBinding.ensureInitialized();

      if(kDebugMode){
         ///cleanCacheFirst

      }
...

This should be useless. At this time, the hot restart has ended, and the ImageCache must be empty. The problem is that native doesn't perceive hot restart, so it never releases textures.

so as long as we can not reach the hot restart begin,this issue will always exists, right? Is there anything else we still can do.🫣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants