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

WkWebView Crash loop on load only with --minifyjs or --prod Ionic compilation #68

Open
adamduren opened this issue Jan 31, 2018 · 3 comments

Comments

@adamduren
Copy link

I am using Ionic along with the WkWebView as suggested in my application and ran into an error where the app would continually crash when using the --prod flag. It continually tries to reload the app which triggers the issue again. Usually after reloading anywhere from 3-10 times it resolves itself. I tried varying various ionic options and found --minifyjs to be the culprit.

It seems like there might be two issues. One is that the WkWebView should not crash as a result of minified JavaScript. The second question of possible issue is Uglify doing something it shouldn't be doing?

I suspect that this has something to do with loading / rendering a large amount of data from the backend (firebase) although I can not explain why it only happens when minified. When I remove the data fetch it no longer occurs. Large in this case is relative but it started happening when I started querying for over 200 items.

We need a way to disable WkWebView from trying to automatically recover from a crash or to be able to set a maximum retry limit as it's making a massive amount of queries and burning through quotas. I can stop this in development but we have customers in production with this issue.

As far as debugging goes I cannot see if there are any console entries as the app crashes before I am able to attach the Safari debugger. Logs are also not being streamed to my console if they are being produced. I have attacked the stack trace of the failing thread and well as some console output from xcode.

In my debugging I switched back to UIWebView which did not have this issue.

Relevant package.json entiries

"ionic": "3.19.1",
"ionic-angular": "^3.9.2",
"@ionic/app-scripts": "^3.1.8",
"cordova-ios": "^4.5.4",
"cordova-plugin-ionic-webview": "^1.1.16",

Stacktrace:

Thread 7 name:  WTF::AutomaticThread
Thread 7 Crashed:
0   JavaScriptCore                	0x000000018ab911b8 WTFCrashWithInfo+ 9925048 (int, char const*, char const*, int) + 0
1   JavaScriptCore                	0x000000018a574a4c JSC::DFG::AbstractInterpreter<JSC::DFG::InPlaceAbstractState>::executeEffects+ 3517004 (unsigned int, JSC::DFG::Node*) + 39036
2   JavaScriptCore                	0x000000018a566f74 JSC::DFG::CFAPhase::performBlockCFA+ 3460980 (JSC::DFG::BasicBlock*) + 728
3   JavaScriptCore                	0x000000018a56676c JSC::DFG::CFAPhase::run+ 3458924 () + 280
4   JavaScriptCore                	0x000000018a5664d4 bool JSC::DFG::runAndLog<JSC::DFG::CFAPhase>+ 3458260 (JSC::DFG::CFAPhase&) + 56
5   JavaScriptCore                	0x000000018a2a2248 bool JSC::DFG::runPhase<JSC::DFG::CFAPhase>+ 557640 (JSC::DFG::Graph&) + 48
6   JavaScriptCore                	0x000000018a665c38 JSC::DFG::Plan::compileInThreadImpl+ 4504632 () + 1956
7   JavaScriptCore                	0x000000018a664f64 JSC::DFG::Plan::compileInThread+ 4501348 (JSC::DFG::ThreadData*) + 644
8   JavaScriptCore                	0x000000018a7133ec JSC::DFG::Worklist::ThreadBody::work+ 5215212 () + 320
9   JavaScriptCore                	0x000000018ab95318 WTF::Function<void ()>::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0>::call+ 9941784 () + 360
10  JavaScriptCore                	0x000000018a22570c WTF::threadEntryPoint+ 46860 (void*) + 120
11  JavaScriptCore                	0x000000018a22564c WTF::wtfThreadEntryPoint+ 46668 (void*) + 84
12  libsystem_pthread.dylib       	0x00000001834802b4 _pthread_body + 308
13  libsystem_pthread.dylib       	0x0000000183480180 _pthread_body + 0
14  libsystem_pthread.dylib       	0x000000018347eb74 thread_start + 4

XCode Logs

2018-01-31 11:46:01.898798-0500 IonicApp[806:315416] Apache Cordova native platform version 4.5.3 is starting.
2018-01-31 11:46:01.900179-0500 IonicApp[806:315416] Multi-tasking -> Device: YES, App: YES
2018-01-31 11:46:01.919945-0500 IonicApp[806:315416] CDVWKWebViewEngine: trying to inject XHR polyfill
2018-01-31 11:46:01.986398-0500 IonicApp[806:315416] [MC] Lazy loading NSBundle MobileCoreServices.framework
2018-01-31 11:46:01.986643-0500 IonicApp[806:315416] [MC] Loaded MobileCoreServices.framework
2018-01-31 11:46:01.993397-0500 IonicApp[806:315416] CDVWKWebViewEngine will reload WKWebView if required on resume
2018-01-31 11:46:01.993533-0500 IonicApp[806:315416] Using Ionic WKWebView
2018-01-31 11:46:01.994142-0500 IonicApp[806:315416] [CDVTimer][console] 0.212073ms
2018-01-31 11:46:01.994396-0500 IonicApp[806:315416] [CDVTimer][handleopenurl] 0.130057ms
2018-01-31 11:46:01.997296-0500 IonicApp[806:315416] [CDVTimer][intentandnavigationfilter] 2.807975ms
2018-01-31 11:46:01.997550-0500 IonicApp[806:315416] [CDVTimer][gesturehandler] 0.130057ms
2018-01-31 11:46:02.040939-0500 IonicApp[806:315416] [CDVTimer][statusbar] 43.223977ms
2018-01-31 11:46:02.043696-0500 IonicApp[806:315416] [CDVTimer][keyboard] 2.407908ms
2018-01-31 11:46:02.057501-0500 IonicApp[806:315416] [CDVTimer][splashscreen] 13.637066ms
2018-01-31 11:46:02.057631-0500 IonicApp[806:315416] [CDVTimer][TotalPluginStartup] 63.753009ms
2018-01-31 11:46:03.767100-0500 IonicApp[806:315416] Ionic Native: deviceready event fired after 581 ms
2018-01-31 11:46:06.193721-0500 IonicApp[806:315500] [ProcessSuspension]  0x1c4670340 - ProcessAssertion() Unable to acquire assertion for process with PID 0
2018-01-31 11:46:07.682214-0500 IonicApp[806:315416] Ionic Native: deviceready event fired after 680 ms
2018-01-31 11:46:09.782389-0500 IonicApp[806:315501] [ProcessSuspension]  0x1c0275b40 - ProcessAssertion() Unable to acquire assertion for process with PID 0

...the deviceready and ProcessSuspension lines loop until for some reason reloading does not cause a crash
@hartherbert
Copy link

having the same issue using the --prod flag

@adamduren
Copy link
Author

@hartherbert Does it work for you if you use ionic cordova run ios --aot --minifycss --optimizejs? I believe that's all of the prod flags minus --minifyjs. Trying to figure out of it's strictly uglifyjs or a combination of things.

@hartherbert
Copy link

It's hard to tell if it works with only those flags ionic cordova run ios --aot --minifycss --optimizejs because it doesnt fail everytime.
In my case I am using onic cordova run ios --aot --minifycss --release

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