vinnichase opened a new issue #138: Possible Race Condition on iPhone 11 Pro on 
Start Up
URL: https://github.com/apache/cordova-plugin-wkwebview-engine/issues/138
 
 
   # Bug Report
   ## Problem
   Our customers report random white screens on app launch on iOS devices. 
While almost all devices happen to launch the app successfully after some 
retries the iPhone 11 Pro always starts with a white screen. That got me (after 
long blackbox digging) to the assumption that fast iPhones have the Problem and 
that WKWebView maybe starts with a race condition.
   
   On my iPhone 11 Pro simulator I luckily got a 50/50 chance of a white screen 
so I started debugging `CDVWKWebKitViewEngine.m`. I have absolutely no 
knowledge in Objective-C so I just restarted over and over again to spot 
randomly the differences in the call stack. While doing this I slowly got an 
understanding of how the plugin might be working under the hood. 
`userContentController:didReceiveScriptMessage` seems to play a role in the 
successful startup of the container and all scripts and assets being loaded.
   
   After a long time I recognized that breaking the code at line 321 in 
`CDVWKWebKitViewEngine.m` got the app working constantly in the simulator which 
brought me adding a sleep timer in line 321:
   
   ```ObjectiveC
   - (id)forwardingTargetForSelector:(SEL)aSelector
   {
       [NSThread sleepForTimeInterval:1.0];
       return _engineWebView;
   }
   ```
   That at least got the app starting without breakpoints in the simulator. 
However on the physical device it kept the white screen.
   
   I will now go on debugging to spot another point. But any help or hints are 
highly appreciated.
   
   ### What is expected to happen?
   App should start correctly after splash screen.`CDVWKWebKitViewEngine.m` -> 
`userContentController:didReceiveScriptMessage` should be fired on every App 
start reliably.
   
   ### What does actually happen?
   `userContentController:didReceiveScriptMessage` is only fired on iPhone 11 
Pro Simulator, iOS 13.3 when `[NSThread sleepForTimeInterval:1.0];` is added in 
line 321 in `CDVWKWebKitViewEngine.m`:
   
   ```ObjectiveC
   - (id)forwardingTargetForSelector:(SEL)aSelector
   {
       [NSThread sleepForTimeInterval:1.0];
       return _engineWebView;
   }
   ```
   
   Without adding the sleep line I encounter a white screen in 5 out of 10 
cases in the simulator. `userContentController:didReceiveScriptMessage` is not 
fired in those cases.
   
   On physical iPhone 11 Pro, iOS 13.3.1 the app launches constantly with a 
white screen after splash and 
   `userContentController:didReceiveScriptMessage` is not fired - even if I set 
the sleep to 5 seconds.
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   - iPhone 11 Pro Simulator, iOS 13.3 (App starts after 1 sec sleep hack)
   - iPhone 11 Pro, iOS 13.3.1 (Still broken)
   
   ### Version information
   
   Cordova:
    - 9.0.0 ([email protected])
    - cordova-plugin-camera: 4.1.0
    - cordova-plugin-device: 2.0.3
    - cordova-plugin-dialogs: 2.0.2
    - cordova-plugin-file: 6.0.2
    - cordova-plugin-media-capture: 3.0.3
    - cordova-plugin-statusbar: 2.4.3
    - cordova-plugin-wkkeyboardfix: 1.0.1
    - cordova-plugin-wkwebviewxhrfix: 0.1.0
   
   React:
    - onsenui: 2.10.8
    - react: 16.8.6
   
   XCode: 11.3.1
   MacOS Catalina 10.15.4
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to