Fix #1232: Reload issue resulting in white screen #1235
+9
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1232
Fixes meteor/meteor#11811
Platforms affected
iOS
Motivation and Context
If the iOS system kills the WKWebView processes due to e.g. memory issues, the Cordova app tries to reload the current URL on becoming foreground here:
cordova-ios/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m
Lines 530 to 533 in 67b0bb2
Due to client side routing, the current page may not be the correct initial URL (which includes an access token e.g.). Hence, some apps show a blank screen due to failure of reloading.
See #1232 and meteor/meteor#11811 for an in-depth analysis of the problem and a feasible replication.
#1232 also indicates that the logic behind
shouldReloadWebView
could be an additional problem. @gouteru describes a further fix in #1232 (comment) where they change this logic. As I found that the tests incordova-ios/tests/CordovaLibTests/CDVWebViewEngineTest.m
Lines 191 to 193 in 67b0bb2
explicitly state that an empty title should not result in a reload, I decided to not include they fix. But it could also be possible that the fix is required, as a result, the tests would have to be changed accordingly. If checking the title for 0 lengthiness is strictly required for your use case, please correct me @gouteru.
Description
Since a reload is not sufficient,
CDVWebViewEngine.m
gets the initial app URL viaCDVViewController
(by makingappUrl
a public method) and initiates a new request with the initial app URL. The splashscreen is shown before the new request to hide a temporary white screen from the user.Testing
I used the changes with my Meteor/Cordova app on different iOS devices and I could not detect any white screen.
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)