Skip to content

[flutter 3.29.3] Crashlytics report of ANR io.flutter.embedding.engine.FlutterJNI.nativeSurfaceDestroyed #169585

Open

Description

@a-h-mzd

Steps to reproduce

Random in production

Expected results

no report the issue

Actual results

Crashlytics report ANR

Code sample

Code sample
No sample

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
io.flutter.embedding.engine.FlutterJNI.nativeSurfaceDestroyed (FlutterJNI.java)
io.flutter.embedding.engine.FlutterJNI.onSurfaceDestroyed (FlutterJNI.java:713)
io.flutter.embedding.engine.renderer.FlutterRenderer.stopRenderingToSurface (FlutterRenderer.java:1144)
io.flutter.embedding.android.FlutterSurfaceView.disconnectSurfaceFromRenderer (FlutterSurfaceView.java:303)
io.flutter.embedding.android.FlutterSurfaceView.access$400 (FlutterSurfaceView.java:36)
io.flutter.embedding.android.FlutterSurfaceView$1.surfaceDestroyed (FlutterSurfaceView.java:78)
android.view.SurfaceView.notifySurfaceDestroyed (SurfaceView.java:2132)
android.view.SurfaceView.updateSurface (SurfaceView.java:1230)
android.view.SurfaceView.setWindowStopped (SurfaceView.java:403)
android.view.SurfaceView.surfaceDestroyed (SurfaceView.java:2004)
android.view.ViewRootImpl.notifySurfaceDestroyed (ViewRootImpl.java:2962)
android.view.ViewRootImpl.setWindowStopped (ViewRootImpl.java:2918)
android.view.WindowManagerGlobal.setStoppedState (WindowManagerGlobal.java:830)
android.app.Activity.performStop (Activity.java:9261)
android.app.ActivityThread.callActivityOnStop (ActivityThread.java:5898)
android.app.ActivityThread.performStopActivityInner (ActivityThread.java:5872)
android.app.ActivityThread.handleStopActivity (ActivityThread.java:5943)
android.app.servertransaction.StopActivityItem.execute (StopActivityItem.java:43)
android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:180)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:98)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:2685)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loopOnce (Looper.java:230)
android.os.Looper.loop (Looper.java:319)
android.app.ActivityThread.main (ActivityThread.java:8934)
java.lang.reflect.Method.invoke (Native method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. a-h-mzd commented on May 28, 2025

    @a-h-mzd
    Author

    This looks like this issue #160357. I only created a new issue because the other was closed. We're getting this error for app built using Flutter version 3.29.3

  2. tirth-patel-nc commented on May 29, 2025

    @tirth-patel-nc
    Member

    Hi @a-h-mzd, is that all the information from crashlytics? is there any more dump or stacktrace available? also, are you running with the --no-enable-impeller flag?

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 29, 2025
  4. a-h-mzd commented on May 30, 2025

    @a-h-mzd
    Author

    Hi @tirth-patel-nc, that's all the information we have from Crashlytics. No, we're not using the --no-enable-impeller flag.

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 30, 2025
  6. tirth-patel-nc commented on May 30, 2025

    @tirth-patel-nc
    Member

    Alright. I will keep the issue open based on this Stacktrace. Ideally we would require a reproducible case in order to analyze further & make it actionable.

    @a-h-mzd if possible, can you check if you’re seeing a similar stacktrace on the latest stable version?

  7. added
    c: crashStack traces logged to the console
    engineflutter/engine related. See also e: labels.
    a: productionIssues experienced in live production apps
    needs repro infoAutomated crash report whose cause isn't yet known
    e: impellerImpeller rendering backend issues and features requests
    platform-androidAndroid applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on May 30, 2025
  8. 9 remaining items

  9. littleGnAl commented on Sep 1, 2025

    @littleGnAl
    Contributor

    Hello @a-h-mzd @krfgutierrez, do you face the same issue on Flutter SDK 3.35.x?

  10. a-h-mzd commented on Sep 2, 2025

    @a-h-mzd
    Author

    We have recently released a new version of our app with the latest flutter version(3.35.2) and we have not YET seen this issue.

  11. ChibangLW commented on Sep 3, 2025

    @ChibangLW

    We still see the issue with Flutter v3.35.1. We have not yet updated to 3.35.2.

  12. krfgutierrez commented on Sep 3, 2025

    @krfgutierrez

    Hello @a-h-mzd @krfgutierrez, do you face the same issue on Flutter SDK 3.35.x?

    We haven't updated yet since we're waiting for official fix instead of updating then checking if it is fixed.

  13. ashraf-patel-hs commented on Sep 28, 2025

    @ashraf-patel-hs
  14. qinfendezhou commented on Jan 21, 2026

    @qinfendezhou

    This issue still persists in Flutter version 3.35.0. I will try upgrading to version 3.35.2 to see if it fixes the problem.

  15. marked Android 11 ANR #180947 as a duplicate of this issue on Jan 27, 2026
  16. kisrar commented on Feb 1, 2026

    @kisrar

    The issue till persists in Flutter 3.38.8

  17. qinfendezhou commented on Feb 2, 2026

    @qinfendezhou

    After a week of testing, unfortunately, the problem still exists in version 3.35.2.

  18. qinfendezhou commented on Feb 4, 2026

    @qinfendezhou

    I’d like to share what I found from production analytics, because the repro is random.
    What I found (Firebase analytics breadcrumbs)
    By analyzing our Firebase Analytics / Crashlytics breadcrumbs & event logs, the ANR most commonly happens under this scenario:
    The app is playing a video resource (audio + video) at the time of the ANR.
    During video playback, an ad is shown, and in our app flow showing the ad can cause the app to transition to background (Activity stop / surface destroyed path).
    So the typical sequence is roughly:

    1. Start playing a video (using media_kit)
    2. AdMob ad is shown (or fails / transitions)
    3. App goes to background / Activity is stopped
    4. ANR occurs in nativeSurfaceDestroyed
      Dependencies
      Player: media_kit / media_kit_video
      Ads: Google Mobile Ads (AdMob) (google_mobile_ads)
  19. littleGnAl commented on Feb 9, 2026

    @littleGnAl
    Contributor

    In our add-to-app scenario, the APM report showed the following logs:

    ERROR flutter [ERROR:flutter/impeller/renderer/backend/vulkan/swapchain/khr/khr_swapchain_impl_vk.cc(387)] Impeller validation: Could not acquire next swapchain image: Timeout
    ERROR flutter [ERROR:flutter/shell/gpu/gpu_surface_vulkan_impeller.cc(95)] No surface available.
    

    We mix FlutterTextView and FlutterSurfaceView by using RenderMode.texture and RenderMode.surface. It's most likely this issue caused by FlutterTextView (i.e., RenderMode.texture) in our case.

  20. gaaclarke commented on Mar 2, 2026

    @gaaclarke
    Member

    An internal customer in b/488786379 experienced a similar issue and also stated that switching from RenderMode.texture to RenderMode.surface seemed to address their issue, but also mentioned there are tradeoffs to that change.

  21. ZS-James2026 commented on Mar 16, 2026

    @ZS-James2026

    Environment

    • Flutter Engine Version: V3.32.8
    • Android Manifest meta-data config:
    <application>
       ...
      <meta-data
                android:name="flutterEmbedding"
                android:value="2" />
            <meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false" />
            <meta-data android:name="io.flutter.embedding.android.DisableMergedPlatformUIThread" android:value="true" />
    </application>
    

    backtrace:

    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    pid: 0, tid: 16490 >>> APP_PACKAGE <<<
    
    backtrace:
      #00  pc 0x000000000004b50c  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
      #01  pc 0x000000000004f1f8  /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, timespec const*)+144)
      #02  pc 0x00000000000afc0c  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_cond_wait+60)
      #03  pc 0x00000000004bc540  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/split_config.arm64_v8a.apk!libflutter.so (std::_fl::condition_variable::wait(std::_fl::unique_lock<std::_fl::mutex>&)+71548928) (BuildId: fe6a2478b3359b3e92f9c4f6ebb12f6dc34712c2)
      #04  pc 0x00000000004d08ac  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/split_config.arm64_v8a.apk!libflutter.so (fml::AutoResetWaitableEvent::Wait()+71548928) (BuildId: fe6a2478b3359b3e92f9c4f6ebb12f6dc34712c2)
      #05  pc 0x000000000082fc3c  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/split_config.arm64_v8a.apk!libflutter.so (flutter::Shell::OnPlatformViewDestroyed()+71548928) (BuildId: fe6a2478b3359b3e92f9c4f6ebb12f6dc34712c2)
      #06  pc 0x00000000004b1b88  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/split_config.arm64_v8a.apk!libflutter.so (flutter::PlatformViewAndroid::NotifyDestroyed()+71548928) (BuildId: fe6a2478b3359b3e92f9c4f6ebb12f6dc34712c2)
      #07  pc 0x00000000004b4344  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/split_config.arm64_v8a.apk!libflutter.so (flutter::SurfaceDestroyed(_JNIEnv*, _jobject*, long)+71548928) (BuildId: fe6a2478b3359b3e92f9c4f6ebb12f6dc34712c2)
      #08  pc 0x00000000001a1324  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/oat/arm64/base.odex (art_jni_trampoline+132)
      #09  pc 0x00000000004a5e74  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/oat/arm64/base.odex (io.flutter.embedding.engine.FlutterJNI.onSurfaceDestroyed+116)
      #10  pc 0x00000000005936fc  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/oat/arm64/base.odex (io.flutter.embedding.engine.renderer.FlutterRenderer.stopRenderingToSurface+76)
      #11  pc 0x00000000004a307c  /data/app/~~6C00Zk5bSBN7xEd2aI9pfg==/APP_PACKAGE-iTK82V2Sja4CIiETQdztKQ==/oat/arm64/base.odex (io.flutter.embedding.android.FlutterSurfaceView$1.surfaceDestroyed+220)
      #12  pc 0x0000000000134564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548)
      #13  pc 0x00000000001aa7e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
      #14  pc 0x000000000031d350  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376)
      #15  pc 0x0000000000313538  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912)
      #16  pc 0x000000000068a8a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1036)
      #17  pc 0x000000000012ea14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20)
      #18  pc 0x000000000028d7d6  /system/framework/framework.jar (android.view.SurfaceView.notifySurfaceDestroyed+102)
      #19  pc 0x000000000030a7e0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.9732425425261934293)+264)
      #20  pc 0x00000000006778c8  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776)
      #21  pc 0x000000000013dff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88)
      #22  pc 0x00000000009fe1ac  /system/framework/arm64/boot-framework.oat (android.view.SurfaceView.updateSurface+6572)
      #23  pc 0x00000000009fc298  /system/framework/arm64/boot-framework.oat (android.view.SurfaceView.onWindowVisibilityChanged+184)
      #24  pc 0x00000000009373e8  /system/framework/arm64/boot-framework.oat (android.view.View.dispatchWindowVisibilityChanged+40)
      #25  pc 0x0000000000a0be28  /system/framework/arm64/boot-framework.oat (android.view.ViewGroup.dispatchWindowVisibilityChanged+152)
      #26  pc 0x0000000000a0be28  /system/framework/arm64/boot-framework.oat (android.view.ViewGroup.dispatchWindowVisibilityChanged+152)
      #27  pc 0x0000000000a0be28  /system/framework/arm64/boot-framework.oat (android.view.ViewGroup.dispatchWindowVisibilityChanged+152)
      #28  pc 0x0000000000a0be28  /system/framework/arm64/boot-framework.oat (android.view.ViewGroup.dispatchWindowVisibilityChanged+152)
      #29  pc 0x0000000000a0be28  /system/framework/arm64/boot-framework.oat (android.view.ViewGroup.dispatchWindowVisibilityChanged+152)
      #30  pc 0x000000000096c1e8  /system/framework/arm64/boot-framework.oat (android.view.ViewRootImpl.performTraversals+1672)
      #31  pc 0x00000000009749c0  /system/framework/arm64/boot-framework.oat (android.view.ViewRootImpl.doTraversal+592)
      #32  pc 0x00000000004761ec  /system/framework/arm64/boot-framework.oat (android.content.ContextWrapper.getAssets [DEDUPED]+60)
      #33  pc 0x0000000000811d04  /system/framework/arm64/boot-framework.oat (android.view.Choreographer$CallbackRecord.run+580)
      #34  pc 0x000000000081367c  /system/framework/arm64/boot-framework.oat (android.view.Choreographer.doCallbacks+1388)
      #35  pc 0x0000000000814274  /system/framework/arm64/boot-framework.oat (android.view.Choreographer.doFrame+2468)
      #36  pc 0x000000000090a718  /system/framework/arm64/boot-framework.oat (android.view.Choreographer$FrameDisplayEventReceiver.run+72)
      #37  pc 0x0000000000650e8c  /system/framework/arm64/boot-framework.oat (android.os.Handler.dispatchMessage+76)
      #38  pc 0x000000000065449c  /system/framework/arm64/boot-framework.oat (android.os.Looper.loop+1692)
    

    Using Flutter PlatformViewLink + AndroidViewSurface for native Android view integration

    Is there any estimated Flutter Engine version that will fix this issue? Alternatively, Is there any suggestions or workarounds to prevent the app from crashing?

  22. littleGnAl commented on Apr 14, 2026

    @littleGnAl
    Contributor

    In our add-to-app scenario, the APM report showed the following logs:

    ERROR flutter [ERROR:flutter/impeller/renderer/backend/vulkan/swapchain/khr/khr_swapchain_impl_vk.cc(387)] Impeller validation: Could not acquire next swapchain image: Timeout
    ERROR flutter [ERROR:flutter/shell/gpu/gpu_surface_vulkan_impeller.cc(95)] No surface available.
    

    We mix FlutterTextView and FlutterSurfaceView by using RenderMode.texture and RenderMode.surface. It's most likely this issue caused by FlutterTextView (i.e., RenderMode.texture) in our case.

    An internal customer in b/488786379 experienced a similar issue and also stated that switching from RenderMode.texture to RenderMode.surface seemed to address their issue, but also mentioned there are tradeoffs to that change.

    Hello @gaaclarke @jason-simmons , could you please confirm whether #183288 fixes the issue?

  23. jason-simmons commented on Apr 14, 2026

    @jason-simmons
    Contributor

    #183288 fixed the Could not acquire next swapchain image / No surface available Vulkan swapchain issue that was seen by the internal customer.

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

    P2Important issues not at the top of the work lista: productionIssues experienced in live production appsc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.needs repro infoAutomated crash report whose cause isn't yet knownplatform-androidAndroid applications specificallyteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions