Skip to content

App Freezing on Hot Reload when using FutureBuilder and MethodChannel #30911

Closed

Description

@p30arena

App crashes when Navigating between Widgets.

04-11 16:10:10.014 32656-32691/? E/ContactsProvider_EventLog: Flush buffer to file cnt : 1 size : 0Kb duration : 6ms lastUpdatedAfter : 20672 ms mFlush_time_threasold : 2000 mCurrentSize : 360
04-11 16:10:10.306 9139-9139/ir.yabco.flutter.goggles A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x6e61724d in tid 9139 (flutter.goggles)
                                                              
                                                              [ 04-11 16:10:10.308  2220: 2220 W/         ]
                                                              debuggerd: handling request: pid=9139 uid=10239 gid=10239 tid=9139
04-11 16:10:10.394 9899-9899/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-11 16:10:10.394 9899-9899/? A/DEBUG: Build fingerprint: 'samsung/a5xeltexx/a5xelte:7.0/NRD90M/A510FXXS7CRJA:user/release-keys'
04-11 16:10:10.394 9899-9899/? A/DEBUG: Revision: '9'
04-11 16:10:10.395 9899-9899/? A/DEBUG: ABI: 'arm'
04-11 16:10:10.395 9899-9899/? A/DEBUG: pid: 9139, tid: 9139, name: flutter.goggles  >>> ir.yabco.flutter.goggles <<<
04-11 16:10:10.395 9899-9899/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x6e61724d
04-11 16:10:10.395 9899-9899/? A/DEBUG:     r0 c2b2bbe0  r1 00000004  r2 0000000b  r3 0000004d
04-11 16:10:10.395 9899-9899/? A/DEBUG:     r4 00000004  r5 df7b5e08  r6 0000000b  r7 00000051
04-11 16:10:10.395 9899-9899/? A/DEBUG:     r8 6e617249  r9 cd0b3f24  sl 0000000a  fp 0000000a
04-11 16:10:10.396 9899-9899/? A/DEBUG:     ip ff91c250  sp ff91c208  lr cdaaba17  pc cdaaba36  cpsr 200b0030
04-11 16:10:10.975 9899-9899/? A/DEBUG: backtrace:
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #00 pc 00aeca36  /data/app/ir.yabco.flutter.goggles-1/lib/arm/libflutter.so (offset 0xae8000)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #01 pc 00aebe5d  /data/app/ir.yabco.flutter.goggles-1/lib/arm/libflutter.so (offset 0xae8000)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #02 pc 00aebd8b  /data/app/ir.yabco.flutter.goggles-1/lib/arm/libflutter.so (offset 0xae8000)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #03 pc 00b1ba07  /data/app/ir.yabco.flutter.goggles-1/lib/arm/libflutter.so (offset 0xae8000)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #04 pc 00af68b7  /data/app/ir.yabco.flutter.goggles-1/lib/arm/libflutter.so (offset 0xae8000)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #05 pc 00af93c3  /data/app/ir.yabco.flutter.goggles-1/lib/arm/libflutter.so (offset 0xae8000)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #06 pc 00011fcb  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+614)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #07 pc 00011cd7  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+26)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #08 pc 000972dd  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+22)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #09 pc 0260e3a5  /system/framework/arm/boot-framework.oat (offset 0x1ef8000) (android.os.MessageQueue.nativePollOnce+96)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #10 pc 0260f8c1  /system/framework/arm/boot-framework.oat (offset 0x1ef8000) (android.os.MessageQueue.next+188)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #11 pc 0260afa9  /system/framework/arm/boot-framework.oat (offset 0x1ef8000) (android.os.Looper.loop+364)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #12 pc 01f8ef93  /system/framework/arm/boot-framework.oat (offset 0x1ef8000) (android.app.ActivityThread.main+598)
04-11 16:10:10.975 9899-9899/? A/DEBUG:     #13 pc 000a9341  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #14 pc 00407961  /system/lib/libart.so (art_quick_invoke_static_stub+228)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #15 pc 000b065f  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+182)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #16 pc 00316d0b  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+58)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #17 pc 0031807f  /system/lib/libart.so (_ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_j+766)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #18 pc 002be761  /system/lib/libart.so (_ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_S3_+40)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #19 pc 00606159  /system/framework/arm/boot.oat (offset 0x56f000) (java.lang.reflect.Method.invoke+116)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #20 pc 02bb5a01  /system/framework/arm/boot-framework.oat (offset 0x1ef8000) (com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run+100)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #21 pc 02bb7055  /system/framework/arm/boot-framework.oat (offset 0x1ef8000) (com.android.internal.os.ZygoteInit.main+1680)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #22 pc 000a9341  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #23 pc 00407961  /system/lib/libart.so (art_quick_invoke_static_stub+228)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #24 pc 000b065f  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+182)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #25 pc 00316d0b  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+58)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #26 pc 00316b1b  /system/lib/libart.so (_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDSt9__va_list+266)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #27 pc 00278b17  /system/lib/libart.so (_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+426)
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #28 pc 0006a595  /system/lib/libandroid_runtime.so
04-11 16:10:10.976 9899-9899/? A/DEBUG:     #29 pc 0006c00b  /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime5startEPKcRKNS_6VectorINS_7String8EEEb+510)
04-11 16:10:10.977 9899-9899/? A/DEBUG:     #30 pc 00002e67  /system/bin/app_process32
04-11 16:10:10.977 9899-9899/? A/DEBUG:     #31 pc 00016d79  /system/lib/libc.so (__libc_init+48)
04-11 16:10:10.977 9899-9899/? A/DEBUG:     #32 pc 0000295c  /system/bin/app_process32
                                        
                                        
                                        [ 04-11 16:10:11.539  9899: 9899 E/         ]
                                        ro.debug_level = 0x4f4c
                                        
                                        [ 04-11 16:10:11.539  9899: 9899 E/         ]
                                        sys.mobilecare.preload = false
04-11 16:10:11.541 2228-2228/? E/audit: type=1701 audit(1554982811.531:362684): auid=4294967295 uid=10239 gid=10239 ses=4294967295 subj=u:r:untrusted_app:s0:c512,c768 pid=9139 comm="flutter.goggles" reason="memory violation" sig=11
04-11 16:10:11.574 2334-2334/? E/lowmemorykiller: Error writing /proc/9139/oom_score_adj; errno=22
04-11 16:10:11.682 2904-3018/? E/InputDispatcher: channel ~ Channel is unrecoverably broken and will be disposed!

Activity

  1. p30arena commented on Apr 11, 2019

    @p30arena
    ContributorAuthor
    [√] Flutter (Channel master, v1.4.16-pre.15, on Microsoft Windows [Version 6.3.9600], locale en-US)
        • Flutter version 1.4.16-pre.15 at M:\flutter
        • Framework revision 1a3201bc74 (8 hours ago), 2019-04-10 20:14:35 -0700
        • Engine revision 72986c39ea
        • Dart version 2.2.1 (build 2.2.1-dev.3.1 None)
    
    [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
        • Android SDK at D:\Android\sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-28, build-tools 28.0.3
        • ANDROID_HOME = D:\Android\sdk
        • Java binary at: C:\Program Files\Java\jdk1.8.0_45\bin\java
        • Java version Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
        • All Android licenses accepted.
    
    [!] Android Studio (not installed)
        • Android Studio not found; download from https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
    
    [√] Connected device (1 available)
        • SM A510F • 33000dbf262c233d • android-arm • Android 7.0 (API 24)
    
    ! Doctor found issues in 1 category.
    
  2. p30arena commented on Apr 11, 2019

    @p30arena
    ContributorAuthor

    I've made a native package, and I'm using a MethodChannel in this widget.

    All methods of this class must be called on the platform thread (Android main thread). For more details see Threading in the Flutter Engine.

    I'm creating a Thread, and calling result.success from the Thread.
    Is this causing the crash?

  3. p30arena commented on Apr 11, 2019

    @p30arena
    ContributorAuthor

    I'm not getting crashes after running result functions on the ui thread
    Is this correct?
    or should I run on another thread?

    private void isImage(final MethodCall call, final Result result) {
        new Thread(new Runnable() {
          @Override
          public void run() {
            Object r = false;
            Exception e = null;
    
            try {
              BitmapFactory.Options options = new BitmapFactory.Options();
              options.inJustDecodeBounds = true;
              Bitmap bitmap = BitmapFactory.decodeFile(String.valueOf(call.arguments), options);
              if (options.outWidth != -1 && options.outHeight != -1) {
                r = true;
              } else {
                r = false;
              }
            } catch (Exception error) {
              error.printStackTrace();
              e = error;
            } finally {
              final Object r1 = r;
              final Exception e1 = e;
    
              registrar.activity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                  if (e1 != null) {
                    result.error("0", "", null);
                  } else {
                    result.success(r1);
                  }
                }
              });
            }
          }
        }).start();
      }
    
  4. p30arena commented on Apr 11, 2019

    @p30arena
    ContributorAuthor

    https://docs.flutter.io/javadoc/io/flutter/plugin/common/MethodChannel.Result.html

    All methods of this class must be called on the platform thread (Android main thread). For more details see Threading in the Flutter Engine.

    https://docs.flutter.io/javadoc/io/flutter/plugin/common/EventChannel.EventSink.html

    Its interesting that I couldn't find the same statement for event sink

  5. p30arena commented on Apr 11, 2019

    @p30arena
    ContributorAuthor

    also my app is freezing on a hot reload

  6. p30arena commented on Apr 11, 2019

    @p30arena
    ContributorAuthor

    I replaced the above code with:

    new Handler(Looper.getMainLooper()).post(new Runnable() {
                  @Override
                  public void run() {
                    if (e1 != null) {
                      result.error("0", "", null);
                    } else {
                      result.success(r1);
                    }
                  }
                });
    

    to make sure that the result methods are being called on the main thread,
    but still, app freezes on hot reloads.

  7. changed the title [-]Weird Crash[/-] [+][Platform] App Crash + Freezing on Hot Reload[/+] on Apr 11, 2019
  8. p30arena commented on Apr 12, 2019

    @p30arena
    ContributorAuthor

    I have to do hot reload 2 times to get the UI working (unfreeze)

    I don't know if this is related to the native plugin or not

  9. p30arena commented on Apr 13, 2019

    @p30arena
    ContributorAuthor

    When I set a break point in the future of FutureBuilder,
    the hot-reload works correctly,
    but when I unset the break point,
    first hot-reload freezes the UI, and the second one unfreezes it.

    It seems that when there's a Fast-Path to Invoking a MethodChannel on Hot-Reload, the UI Freezes, but when there's enough time for something to Happen? the MethodChannel doesn't Freeze the UI.

    But it still doesn't satisfy me, because the second Hot-Reload cleans up the mess of the First one.

    This is only happening in the FutureBuilder

  10. changed the title [-][Platform] App Crash + Freezing on Hot Reload[/-] [+]App Freezing on Hot Reload when using FutureBuilder and MethodChannel[/+] on Apr 13, 2019
  11. techtunde commented on May 4, 2019

    @techtunde

    @p30arena were you able to fix this since you closed the issue?

  12. p30arena commented on May 4, 2019

    @p30arena
    ContributorAuthor
  13. github-actions commented on Aug 30, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: crashStack traces logged to the console

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions