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

InAppBrowser crashes the app when i change the page "Lost connection" #74

Closed
shubhamnatani opened this issue Apr 1, 2019 · 15 comments
Closed

Comments

@shubhamnatani
Copy link

When i run the Flutter app and go to the inappbrowser and then get back to the my origin page.
it crashes the app in ios mode not in android.
Please responded fast as soon as possible.

InAppWebView(
initialUrl: 'www.google.com',
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},

                onProgressChanged: (InAppWebViewController controller, int progress) {
                  setState(() {
                    this.progress = progress/100;
                  });
                },
                
                gestureRecognizers: Set()
                  ..add(Factory<VerticalDragGestureRecognizer>(
                          () => VerticalDragGestureRecognizer())),
              ), 
@pichillilorenzo
Copy link
Owner

Can you post here the logs please?

@shubhamnatani
Copy link
Author

one line is generated.
Lost connection to device when i shift from inappbrowser to my vertical page.

@shubhamnatani
Copy link
Author

Can you please repsond it fast.I am stuck just because of this issue.

@ashbressler
Copy link

I believe that I'm experiencing the same issue. I'm getting the following error in the XCode log:

2019-04-08 15:42:55.196097-0400 Runner[40818:798573] Fatal error: Unexpectedly found nil while unwrapping an Optional value

and in the Stack it looks like it's happening here:

https://github.com/pichillilorenzo/flutter_inappbrowser/blob/master/ios/Classes/InAppWebView.swift#L797

It looks like it's trying to invokeMethod 'onConsoleMessage'

I have attached screenshots of what I think are the debug stack at the time of the crash. If you would like more detail that u can't see in the screens please let me know.

Screen Shot 2019-04-08 at 3 58 45 PM

Screen Shot 2019-04-08 at 3 58 54 PM

Screen Shot 2019-04-08 at 3 58 59 PM

@vigupta7
Copy link

vigupta7 commented Apr 9, 2019

Team, I am facing the same issue with flutter_inappbrowser. I am using it in a page view, i which on first page, the link is shown,and on second page, the webview is loaded.

the Webview loads fine , but when i drag back to first page, the App crashes and just give one error as 'Lost connection to device'. This error is comming for IOS only and not for android.

This is my code ..

return new Scaffold(
appBar: PreferredSize( preferredSize: Size(double.infinity, 40),
child:AppBar(
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios,size: 20.0,),
padding: EdgeInsets.only(top: 8.0,left: 10.0),
onPressed: () => _controller.animateToPage(0,duration: Duration(milliseconds: 300),curve: Curves.ease)),
title: new Center(child:new Text(Url,style: TextStyle(fontSize: 15.0),textAlign: TextAlign.center )),
bottom: _createProgressIndicator(),
actions: [
IconButton(
icon: Icon(Icons.refresh),
padding: EdgeInsets.only(top: 8.0,right: 10.0),
iconSize: 20.0,
onPressed: ()
{
if (webView != null) {
webView.reload();
}
}),
],
),
),
body:
Container(
child: Column(
children: [
_createProgressIndicator(),
Expanded(
child: Container(
margin: const EdgeInsets.all(0.0),
child:
InAppWebView(
initialUrl: appData.newsLink,
initialHeaders: {

                },
                initialOptions: {

                },
                onWebViewCreated: (InAppWebViewController controller) {
                  webView = controller;
                },
                onLoadStart: (InAppWebViewController controller, String url) {
                },
                onProgressChanged: (InAppWebViewController controller, int progress) {
                  setState(() {
                    this.progress = progress/100;
                  });
                },
                gestureRecognizers: Set()
                  ..add(Factory<VerticalDragGestureRecognizer>(
                          () => VerticalDragGestureRecognizer())),
              ),
            ),
          ),
        ].where((Object o) => o != null).toList(),
      ),
);

}

PreferredSize _createProgressIndicator() => PreferredSize(
preferredSize: Size(double.infinity, 1.0),
child: SizedBox(
height: 1.0,
child: (progress != 1.0) ? LinearProgressIndicator(value: progress,backgroundColor: Colors.black,valueColor: AlwaysStoppedAnimation (Colors.white)):null,
)
);

**I have also implemented fabric to do the crash analytics.. and below is the crash error, I got..

I hope, the creators will be able to solve this issue by looking at below crash analytic report.**

Crashlytics - plaintext stacktrace downloaded by XXXX at Tue, 09 Apr 2019 14:25:28 GMT

URL: https://www.fabric.io/xxxx/issues/5cacaaa9f8b88c29633080fa?time=last-seven-days/sessions/4d78b23557ae42e9aa547e0a9cffc3af_DNE_0_v2

Platform: ios

Version: 1.1.0 (2)

Issue ID: 5cacaaa9f8b88c29633080fa

Session ID: 4d78b23557ae42e9aa547e0a9cffc3af_DNE_0_v2

Date: 2019-04-09T14:01:00Z

OS Version: 12.1.2 (16C101)

Device: iPhone 5s

RAM Free: 3.6%

Disk Free: 50.9%

#0. Crashed: com.apple.main-thread
0 flutter_inappbrowser 0x1016397d0 InAppWebView.onProgressChanged(progress:) (InAppWebView.swift:798)
1 flutter_inappbrowser 0x10163b544 @objc InAppWebView.observeValue(forKeyPath:of:change:context:) ()
2 Foundation 0x182426a9c NSKeyValueNotifyObserver + 304
3 Foundation 0x182428f30 NSKeyValueDidChange + 384
4 Foundation 0x182426324 NSKeyValueDidChangeWithPerThreadPendingNotifications.llvm.16432713543580414412 + 144
5 WebKit 0x1914466a4 WebKit::PageLoadState::callObserverCallback(void (WebKit::PageLoadState::Observer::)()) + 160
6 WebKit 0x1914464a4 WebKit::PageLoadState::commitChanges() + 996
7 WebKit 0x1915b2ce4 WebKit::WebPageProxy::didChangeProgress(double) + 104
8 WebKit 0x1915d2220 WebKit::WebPageProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 3680
9 WebKit 0x1913be9f4 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 120
10 WebKit 0x19163ae84 WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 36
11 WebKit 0x1913810e0 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_deleteIPC::Decoder >) + 176
12 WebKit 0x191383870 IPC::Connection::dispatchIncomingMessages() + 752
13 JavaScriptCore 0x188ccbd1c WTF::RunLoop::performWork() + 276
14 JavaScriptCore 0x188ccbfe4 WTF::RunLoop::performWork(void
) + 36
15 CoreFoundation 0x1819411f0 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24
16 CoreFoundation 0x181941170 __CFRunLoopDoSource0 + 88
17 CoreFoundation 0x181940a54 __CFRunLoopDoSources0 + 176
18 CoreFoundation 0x18193b920 __CFRunLoopRun + 1040
19 CoreFoundation 0x18193b1f0 CFRunLoopRunSpecific + 436
20 GraphicsServices 0x183bb4584 GSEventRunModal + 100
21 UIKitCore 0x1aeb42d40 UIApplicationMain + 212
22 Runner 0x1009b9678 main (AppDelegate.swift:5)
23 libdyld.dylib 0x1813fabb4 start + 4

--

#0. Crashed: com.apple.main-thread
0 flutter_inappbrowser 0x1016397d0 InAppWebView.onProgressChanged(progress:) (InAppWebView.swift:798)
1 flutter_inappbrowser 0x10163b544 @objc InAppWebView.observeValue(forKeyPath:of:change:context:) ()
2 Foundation 0x182426a9c NSKeyValueNotifyObserver + 304
3 Foundation 0x182428f30 NSKeyValueDidChange + 384
4 Foundation 0x182426324 NSKeyValueDidChangeWithPerThreadPendingNotifications.llvm.16432713543580414412 + 144
5 WebKit 0x1914466a4 WebKit::PageLoadState::callObserverCallback(void (WebKit::PageLoadState::Observer::)()) + 160
6 WebKit 0x1914464a4 WebKit::PageLoadState::commitChanges() + 996
7 WebKit 0x1915b2ce4 WebKit::WebPageProxy::didChangeProgress(double) + 104
8 WebKit 0x1915d2220 WebKit::WebPageProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 3680
9 WebKit 0x1913be9f4 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 120
10 WebKit 0x19163ae84 WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 36
11 WebKit 0x1913810e0 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_deleteIPC::Decoder >) + 176
12 WebKit 0x191383870 IPC::Connection::dispatchIncomingMessages() + 752
13 JavaScriptCore 0x188ccbd1c WTF::RunLoop::performWork() + 276
14 JavaScriptCore 0x188ccbfe4 WTF::RunLoop::performWork(void
) + 36
15 CoreFoundation 0x1819411f0 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24
16 CoreFoundation 0x181941170 __CFRunLoopDoSource0 + 88
17 CoreFoundation 0x181940a54 __CFRunLoopDoSources0 + 176
18 CoreFoundation 0x18193b920 __CFRunLoopRun + 1040
19 CoreFoundation 0x18193b1f0 CFRunLoopRunSpecific + 436
20 GraphicsServices 0x183bb4584 GSEventRunModal + 100
21 UIKitCore 0x1aeb42d40 UIApplicationMain + 212
22 Runner 0x1009b9678 main (AppDelegate.swift:5)
23 libdyld.dylib 0x1813fabb4 start + 4

#1. com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x18153bea4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x18153b37c mach_msg + 72
2 CoreFoundation 0x181940be8 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x18193ba84 __CFRunLoopRun + 1396
4 CoreFoundation 0x18193b1f0 CFRunLoopRunSpecific + 436
5 Foundation 0x182331494 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
6 Foundation 0x182331340 -[NSRunLoop(NSRunLoop) runUntilDate:] + 148
7 UIKitCore 0x1aec331f4 -[UIEventFetcher threadMain] + 136
8 Foundation 0x18246423c NSThread__start + 1040
9 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
10 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
11 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#2. Thread
0 libsystem_kernel.dylib 0x181547b9c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1815cd100 _pthread_wqthread + 348
2 libsystem_pthread.dylib 0x1815cfcec start_wqthread + 4

#3. io.flutter.1.ui
0 libsystem_kernel.dylib 0x18153bea4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x18153b37c mach_msg + 72
2 CoreFoundation 0x181940be8 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x18193ba84 __CFRunLoopRun + 1396
4 CoreFoundation 0x18193b1f0 CFRunLoopRunSpecific + 436
5 Flutter 0x100ed2858 fml::MessageLoopDarwin::Run() (message_loop_darwin.mm:47)
6 Flutter 0x100ed2100 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)::$_0> >(void*) (message_loop_impl.cc:77)
7 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
8 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
9 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#4. io.flutter.1.gpu
0 libsystem_kernel.dylib 0x18153bea4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x18153b37c mach_msg + 72
2 CoreFoundation 0x181940be8 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x18193ba84 __CFRunLoopRun + 1396
4 CoreFoundation 0x18193b1f0 CFRunLoopRunSpecific + 436
5 Flutter 0x100ed2858 fml::MessageLoopDarwin::Run() (message_loop_darwin.mm:47)
6 Flutter 0x100ed2100 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)::$_0> >(void*) (message_loop_impl.cc:77)
7 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
8 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
9 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#5. io.flutter.1.io
0 libsystem_kernel.dylib 0x18153bea4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x18153b37c mach_msg + 72
2 CoreFoundation 0x181940be8 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x18193ba84 __CFRunLoopRun + 1396
4 CoreFoundation 0x18193b1f0 CFRunLoopRunSpecific + 436
5 Flutter 0x100ed2858 fml::MessageLoopDarwin::Run() (message_loop_darwin.mm:47)
6 Flutter 0x100ed2100 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)::$_0> >(void*) (message_loop_impl.cc:77)
7 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
8 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
9 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#6. Thread
0 libsystem_kernel.dylib 0x18154891c kevent + 8
1 Flutter 0x10117e5c0 dart::bin::EventHandlerImplementation::EventHandlerEntry(unsigned long) (eventhandler_macos.cc:450)
2 Flutter 0x1011ac2d4 dart::bin::ThreadStart(void*) (thread_macos.cc:81)
3 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
4 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
5 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#7. JavaScriptCore bmalloc scavenger
0 libsystem_kernel.dylib 0x181546f0c __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1815c4c88 _pthread_cond_wait$VARIANT$mp + 636
2 libc++.1.dylib 0x180b14568 std::__1::condition_variable::__do_timed_wait(std::__1::unique_lockstd::__1::mutex&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) + 96
3 JavaScriptCore 0x188cf7fe8 std::__1::cv_status std::__1::condition_variable::wait_until<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(std::__1::unique_lockstd::__1::mutex&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > const&) + 124
4 JavaScriptCore 0x188cf7e98 std::__1::cv_status std::__1::condition_variable_any::wait_until<std::__1::unique_lockbmalloc::Mutex, std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(std::__1::unique_lockbmalloc::Mutex&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > const&) + 112
5 JavaScriptCore 0x188cf6b34 bmalloc::Scavenger::threadRunLoop() + 296
6 JavaScriptCore 0x188cf61f0 bmalloc::Scavenger::Scavenger(std::__1::lock_guardbmalloc::Mutex&) + 10
7 JavaScriptCore 0x188cf7c9c std::__1::__thread_specific_ptrstd::__1::__thread_struct::set_pointer(std::__1::__thread_struct*) + 38
8 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
9 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
10 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#8. com.twitter.crashlytics.ios.MachExceptionServer
0 Runner 0x1009d384c CLSProcessRecordAllThreads + 180
1 Runner 0x1009d3c34 CLSProcessRecordAllThreads + 1180
2 Runner 0x1009c34b0 CLSHandler + 48
3 Runner 0x1009be890 CLSMachExceptionServer + 1144
4 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
5 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
6 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#9. Thread
0 libsystem_pthread.dylib 0x1815cfce8 start_wqthread + 190

#10. com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x18153bea4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x18153b37c mach_msg + 72
2 CoreFoundation 0x181940be8 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x18193ba84 __CFRunLoopRun + 1396
4 CoreFoundation 0x18193b1f0 CFRunLoopRunSpecific + 436
5 CFNetwork 0x181f5e00c -[__CoreSchedulingSetRunnable runForever] + 212
6 Foundation 0x18246423c NSThread__start + 1040
7 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
8 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
9 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#11. Thread
0 libsystem_kernel.dylib 0x181547b9c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x1815cd100 _pthread_wqthread + 348
2 libsystem_pthread.dylib 0x1815cfcec start_wqthread + 4

#12. Thread
0 libsystem_kernel.dylib 0x181546f0c __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1815c4cbc _pthread_cond_wait$VARIANT$mp + 688
2 Flutter 0x1012f4fe8 dart::Monitor::WaitMicros(long long) (os_thread_macos.cc:407)
3 Flutter 0x101335368 dart::ThreadPool::Worker::Main(unsigned long) (thread_pool.cc:395)
4 Flutter 0x1012f4a10 dart::ThreadStart(void*) (os_thread_macos.cc:107)
5 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
6 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
7 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#13. Thread
0 libsystem_kernel.dylib 0x181546f0c __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1815c4cbc _pthread_cond_wait$VARIANT$mp + 688
2 Flutter 0x1012f4fe8 dart::Monitor::WaitMicros(long long) (os_thread_macos.cc:407)
3 Flutter 0x101335368 dart::ThreadPool::Worker::Main(unsigned long) (thread_pool.cc:395)
4 Flutter 0x1012f4a10 dart::ThreadStart(void*) (os_thread_macos.cc:107)
5 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
6 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
7 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

#14. Thread
0 libsystem_kernel.dylib 0x181546f0c __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x1815c4cbc _pthread_cond_wait$VARIANT$mp + 688
2 Flutter 0x1012f4fe8 dart::Monitor::WaitMicros(long long) (os_thread_macos.cc:407)
3 Flutter 0x101335368 dart::ThreadPool::Worker::Main(unsigned long) (thread_pool.cc:395)
4 Flutter 0x1012f4a10 dart::ThreadStart(void*) (os_thread_macos.cc:107)
5 libsystem_pthread.dylib 0x1815cc25c _pthread_body + 128
6 libsystem_pthread.dylib 0x1815cc1bc _pthread_start + 48
7 libsystem_pthread.dylib 0x1815cfcf4 thread_start + 4

@vigupta7
Copy link

vigupta7 commented Apr 9, 2019

Screen Shot 2019-04-09 at 8 07 10 PM

screenshot attached

@ashbressler
Copy link

One more screenshot, I set a breakpoint to the line of the crash and you can see that IAWController is nil and the '!' tries to unwrap a nil value throwing the error.

I believe this is nil because I've gone back to the previous page and the Flutter InAppWebView is destroyed however the underlying iOS WebView is still trying to send events.

Screen Shot 2019-04-09 at 11 02 08 AM

@vigupta7
Copy link

Hey pichillilorenzo, Please check and confirm the way to resolve this issue, as there is not webview widget in flutter that gives the onProgressChange event..

Also, If pagechange triggers this issue, I was thinking of a way to dispose the webview at 90% of page change.. please suggest, if there is any function to dispose the webview.

@vigupta7
Copy link

Friends, Any Update on the issue ?

@vigupta7
Copy link

pichillilorenzo, please update on the rectification. this is a serious issue and we are not able to use this plugin.

@pichillilorenzo
Copy link
Owner

Yes! Sorry guys! I will update it as soon as possible!!

@Gentear
Copy link

Gentear commented Apr 23, 2019

@pichillilorenzo Friends, When will it be updated?

@pichillilorenzo
Copy link
Owner

Plugin updated! Try the new version 1.1.2 and let me know if now it works! Thanks

@vigupta7
Copy link

Awesome and Thanks !!
Its working fine now.

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 Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants