Bug 227625

Summary: Reload of MobileSafari and WKWebview when response is received
Product: WebKit Reporter: thorsten.wolf
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: beidson, cdumez
Priority: P2    
Version: Safari 14   
Hardware: iPhone / iPad   
OS: iOS 14   
URL: https://template.neptune-software.com/neptune/sdk/exp_sample_odata_jsonh_v4.html?sap-client=800
Description Flags
Logs of Console.app none

Description thorsten.wolf 2021-07-02 07:02:03 PDT
Created attachment 432790 [details]
Logs of Console.app

We experience unexpected reloads of webpages viewed with MobileSafari and WKWebview when a response payload is received via XMLHttpRequest.

This reload doesn't happen on an iOS Emulator or Safari on Mac OS or on other browsers but it is reproduceable in our App (build using the Cordova Framework and WKWebview) as well as the iOS Mobile Safari.

We tried the following constellations:
- iPhone 11 Pro with iOS 14.6
- iPad Mini 4 with iPad OS 15 Beta 2
- iPad Air 3 with iPad OS 14.6
- iPad Air 1 with iOS 12.4.9

Reproducing the issue:
Open webpage: https://template.neptune-software.com/neptune/sdk/exp_sample_odata_jsonh_v4.html?sap-client=800 in Mobile Safari and press the button "Fetch 25k Entries".

I attach the log of the console.app with the filtered entries for "Errors and Issues" for the timeframe when the reload happens.
Comment 1 Chris Dumez 2021-07-02 09:14:37 PDT
memorystatus: killing process 93055 [com.apple.WebKit.WebContent] in high band FOREGROUND (10) - memorystatus_available_pages: 20893

Looks like a Jetsam due to memory usage being too high. You cannot be using > 1.5GB of memory like that on embedded.
Comment 2 thorsten.wolf 2021-07-06 00:50:11 PDT
Hi Chris Dumez, 

thanks for your super fast reply! This brings us in the direction what we will analyze now.
We didn't notice this log entry since we only looked for "Issues and Failures".

Does anyone have best practices on how to avoid these memory crashes?
I know that in genereal we really need to take care about the memory consumption of our application so we will see what can be optimized in general.

However there might be use cases where big payloads need to be retrieved by the application.
In our specific scenario we are working with Progressive Web Apps or with the Cordova Framework to get an offline capable app. There are many use cases (especially in offline scenarios) where a lot of master data needs to be synced in advance.

Is there any way of influencing if a webkit process is being killed?
In other applications there are solutions where the user is asked if he/she wants to continue or let the process crash (Just thinking about "Program ... is not responsing. Do you want to close it?"

Do we have any possibility like that in Webkit?

Thanks again for your support!

Kind regards
Comment 3 Alexey Proskuryakov 2021-07-07 11:35:42 PDT
Looks like there were two bugs filed for this, duping ot the older one.

There is no way to prevent getting killed for using too much RAM. Perhaps you could store some of the data in IndexedDB to avoid keeping it in memory.

WebKit Bugzilla is not a good place to discuss general Web programming topics, as we use it strictly for WebKit bugs.

*** This bug has been marked as a duplicate of bug 227610 ***