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

Crash happens when HeadlessInAppWebView's dispose function is called in iOS #972

Closed
4 tasks done
faizanaliedu opened this issue Sep 7, 2021 · 9 comments
Closed
4 tasks done
Labels
bug Something isn't working

Comments

@faizanaliedu
Copy link

I cannot reproduce this issue on debug but it happens on the iOS release, the crash comes from end-user on testFlight.
This issue happens when we call HeadlessInAppWebView.dispose(). The issue does not persist when this is removed.

Environment

Technology Version
Flutter version 2.2.3
Plugin version
Android version
iOS version 14.5
Xcode version 12

Device information: Apple iPhone

Steps to reproduce

Code snippet:

@override
  void dispose() {
    super.dispose();
    headlessWebView?.dispose();
  }

This is from the example code in the repository.

  1. Initialize and run headless webview.
  2. Call dispose.

Stacktrace/Logcat

Here is the crash log

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [15991]
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libobjc.A.dylib               	0x0000000197b2ddd0 objc_release + 16 (objc-runtime-new.h:1589)
1   flutter_inappwebview          	0x0000000102802854 HeadlessInAppWebView.dispose() + 200 (<compiler-generated>:0)
2   flutter_inappwebview          	0x0000000102801da0 HeadlessInAppWebView.handle(_:result:) + 340 (HeadlessInAppWebView.swift:29)
3   flutter_inappwebview          	0x000000010280319c implicit closure #2 in implicit closure #1 in HeadlessInAppWebView.init(id:flutterWebView:) + 4 (HeadlessInAppWebView.swift:21)
4   flutter_inappwebview          	0x000000010280319c partial apply for implicit closure #2 in implicit closure #1 in HeadlessInAppWebView.init(id:flutterWebView:) + 20 (<compiler-generated>:0)
5   flutter_inappwebview          	0x0000000102809e14 thunk for @escaping @callee_guaranteed (@guaranteed FlutterMethodCall, @guaranteed @escaping @callee_guaranteed (@in_guaranteed Any?) -> ()) -> () + 96 (<compiler-generated>:0)
6   Flutter                       	0x0000000102d2ce44 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 116 (FlutterChannels.mm:244)
7   Flutter                       	0x0000000102a3f690 flutter::PlatformMessageRouter::HandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>) const + 140 (platform_message_router.mm:27)
8   Flutter                       	0x0000000102a3f690 flutter::PlatformViewIOS::HandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>) + 504 (platform_view_ios.mm:76)
9   Flutter                       	0x0000000102d461a8 flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_38::operator()() const + 88 (shell.cc:1218)
10  Flutter                       	0x0000000102d461a8 decltype(std::__1::forward<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_38&>(fp)()) std::__1::__invoke<flutter::Shell::OnEngineHandlePlatformMessage(fml::... + 88 (type_traits:4425)
11  Flutter                       	0x0000000102d461a8 void std::__1::__invoke_void_return_wrapper<void>::__call<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_38&>(flutter::Shell::OnEngineHandlePlatformMessage(... + 88 (__functional_base:348)
12  Flutter                       	0x0000000102d461a8 std::__1::__function::__alloc_func<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_38, std::__1::allocator<flutter::Shell::OnEngineHandlePlatformMessage(fml:... + 88 (functional:1533)
13  Flutter                       	0x0000000102d461a8 std::__1::__function::__func<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_38, std::__1::allocator<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPt... + 108 (functional:1707)
14  Flutter                       	0x0000000102ce1f78 std::__1::__function::__value_func<void ()>::operator()() const + 12 (functional:1860)
15  Flutter                       	0x0000000102ce1f78 std::__1::function<void ()>::operator()() const + 12 (functional:2419)
16  Flutter                       	0x0000000102ce1f78 fml::MessageLoopImpl::FlushTasks(fml::FlushType) + 1444 (message_loop_impl.cc:130)
17  Flutter                       	0x0000000102ce3df8 fml::MessageLoopImpl::RunExpiredTasksNow() + 8 (message_loop_impl.cc:143)
18  Flutter                       	0x0000000102ce3df8 fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*) + 32 (message_loop_darwin.mm:75)
19  CoreFoundation                	0x0000000182fa11d4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32 (CFRunLoop.c:1807)
20  CoreFoundation                	0x0000000182fa0dd0 __CFRunLoopDoTimer + 1076 (CFRunLoop.c:2415)
21  CoreFoundation                	0x0000000182fa0220 __CFRunLoopDoTimers + 328 (CFRunLoop.c:2575)
22  CoreFoundation                	0x0000000182f99fd4 __CFRunLoopRun + 1944 (CFRunLoop.c:3090)
23  CoreFoundation                	0x0000000182f99308 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3242)
24  GraphicsServices              	0x000000019a61c734 GSEventRunModal + 164 (GSEvent.c:2259)
25  UIKitCore                     	0x0000000185a1775c -[UIApplication _run] + 1072 (UIApplication.m:3269)
26  UIKitCore                     	0x0000000185a1cfcc UIApplicationMain + 168 (UIApplication.m:4740)
27  Runner                        	0x000000010253d728 main + 68 (AppDelegate.swift:5)
28  libdyld.dylib                 	0x0000000182c55cf8 start + 4
@faizanaliedu faizanaliedu added the bug Something isn't working label Sep 7, 2021
@github-actions
Copy link

github-actions bot commented Sep 7, 2021

👋 @faizanaliedu

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

@bitsydarel
Copy link

Same issue here

@bitsydarel
Copy link

libsystem_platform.dylib            0x00000001e9aec29c 987D48D5-3CAA-34D7-9141-C0BD6E2351E8 + 21148
flutter_inappwebview                0x0000000103662890 $s20flutter_inappwebview20HeadlessInAppWebViewC7disposeyyF + 200
flutter_inappwebview                0x0000000103661ddc $s20flutter_inappwebview20HeadlessInAppWebViewC6handle_6resultySo17FlutterMethodCallC_yypSgctF + 340
flutter_inappwebview                0x00000001036631d8 $s20flutter_inappwebview20HeadlessInAppWebViewC2id0afG0ACSS_AA07FlutterfG10ControllerCtcfcySo0I10MethodCallC_yypSgctcACcfu_yAI_yAJctcfu0_TA + 20
flutter_inappwebview                0x0000000103669e50 $sSo17FlutterMethodCallCypSgIegn_Ieggg_AByXlSgIeyBy_IeyByy_TR + 96
Flutter                             0x0000000103d4cdc0 Flutter + 5164480
Flutter                             0x000000010389ff34 Flutter + 261940
Flutter                             0x0000000103ba8db4 Flutter + 3444148
Flutter                             0x0000000103b4e068 Flutter + 3072104
Flutter                             0x0000000103b51098 Flutter + 3084440
CoreFoundation                      0x000000019ddfd1d4 338F58B1-9B75-38A0-B908-E2574AB1D39A + 672212
CoreFoundation                      0x000000019ddfcdd0 338F58B1-9B75-38A0-B908-E2574AB1D39A + 671184
CoreFoundation                      0x000000019ddfc220 338F58B1-9B75-38A0-B908-E2574AB1D39A + 668192
CoreFoundation                      0x000000019ddf5fd4 338F58B1-9B75-38A0-B908-E2574AB1D39A + 643028
CoreFoundation                      0x000000019ddf5308 CFRunLoopRunSpecific + 600
GraphicsServices                    0x00000001b5478734 GSEventRunModal + 164
UIKitCore                           0x00000001a087375c 41D9BF62-8439-3B21-9959-4E27E75C294E + 12363612
UIKitCore                           0x00000001a0878fcc UIApplicationMain + 168
Runner                              0x0000000102e8cd90 Runner + 19856
libdyld.dylib                       0x000000019dab1cf8 FF7D2567-9277-3AA6-B3DD-2C5748E432A6 + 7416

@brianlenz
Copy link

I can also confirm this is occurring in iOS in 5.3.2. No issues in Android. Not sure if it makes a difference, but we are using Flutter 2.5.2.

@hoanglm4
Copy link
Contributor

Same issue on iOS running both simulator and device. Step reproduce:

  1. screen A run HeadlessInAppWebView => goto screen B
  2. From screen B run Navigator.pushNamedAndRemoveUntil(context, screen A, (_) => false) => app is crashed

Version: 5.3.2

@76765357
Copy link

me too

@shyammtp
Copy link

Any workaround for this.

FlutterWebViewController - dealloc
LeakAvoider - dealloc
InAppWebViewMethodHandler - dealloc
flutter: Bearer 259|2fcZzBb45COyJ6Ch3mpLvfhG0pfQy4za4tN29kAP
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xc820dc890)
    frame #0: 0x000000019a3d2bf0 libobjc.A.dylib`objc_release + 16
libobjc.A.dylib`objc_release:
->  0x19a3d2bf0 <+16>: ldr    x10, [x9, #0x20]
    0x19a3d2bf4 <+20>: tbz    w10, #0x2, 0x19a3d2c54    ; <+116>
    0x19a3d2bf8 <+24>: tbz    w8, #0x0, 0x19a3d2c74     ; <+148>
    0x19a3d2bfc <+28>: mov    x9, #0x100000000000000
Target 0: (Runner) stopped.

@hoanglm4
Copy link
Contributor

Using my fork repository workaround for this issue:

flutter_inappwebview:
    git:
      url: https://github.com/hoanglm4/flutter_inappwebview.git
      ref: 42743f23eb11191f07d36be3c2e0db2b7188559f

Copy link

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 and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants