gouteru commented on issue #1232:
URL: https://github.com/apache/cordova-ios/issues/1232#issuecomment-1112812092
Here's additional changes below.
`- (BOOL)shouldReloadWebView:(NSURL*)location title:(NSString*)title
{
BOOL title_is_nil = (title == nil);
BOOL title_is_empty = ([title length] == 0); // added!
BOOL title_is_bad = (title_is_nil || title_is_empty); // added!
BOOL location_is_blank = [[location absoluteString]
isEqualToString:@"about:blank"];
// BOOL reload = (title_is_nil || location_is_blank);
BOOL reload = (title_is_bad || location_is_blank); // added!
#ifdef DEBUG
NSLog(@"%@", @"CDVWebViewEngine shouldReloadWebView::");
NSLog(@"CDVWebViewEngine shouldReloadWebView title: %@", title);
NSLog(@"CDVWebViewEngine shouldReloadWebView title length: %u", [title
length]); // // added!
NSLog(@"CDVWebViewEngine shouldReloadWebView title is nil: %u",
title_is_nil);
NSLog(@"CDVWebViewEngine shouldReloadWebView location: %@", [location
absoluteString]);
NSLog(@"CDVWebViewEngine shouldReloadWebView location is blank: %u",
location_is_blank);
NSLog(@"CDVWebViewEngine shouldReloadWebView reload: %u", reload);
#endif
return reload;
}`
`- (void) onAppWillEnterForeground:(NSNotification*)notification {
if ([self shouldReloadWebView]) {
NSLog(@"%@", @"CDVWebViewEngine reloading!");
NSString *sURL = @"app://localhost/index.html";
NSURL *url = [NSURL URLWithString:sURL];
NSLog(@"onAppWillEnterForeground url: %@", [url absoluteString]);
[(WKWebView*)_engineWebView loadRequest:[NSURLRequest
requestWithURL:url]];
// [(WKWebView*)_engineWebView reload];
}
}`
I think shouldReloadWebView's title check is insufficient. In my app's case
when WebContent process is terminated, title is not nil but empty string. So,
empty string check should be added.
With the changes above, my app works fine when WebContent process is
terminated while app is in background. When app back in foreground,
shouldReloadWebView detects properly and then load index.html.
With this change, when WebContent process is terminated while my app is in
background, and then back in foreground, 2 functions "onAppWillEnterForeground"
and "webViewWebContentProcessDidTerminate" do loadRequest. As long as my test,
2 times of loadRequest is not making any issue.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]