Detecting browser tab crash in mobile Safari

449 Views Asked by At

We are building a web application that sometimes crashes in Mobile Safari due to a jetsam event, where the OS kills the process because of bad memory usage. We think we have a handle on the bug, but some testing shows that it still very occasionally happens, so we want to build some monitoring to gather details on when it happens. Is there a reliable way to detect when the tab crashes that avoids false positives when the tab is closed? Looking at the device logs at the jetsam event, the web process PID (which I believe is just the affected tab since the other tabs were okay) is killed.

Our current plan was to listen to visibilitychange and detect pairs of hidden and visible events, and then count times that we only saw the visible event as a "session crash". However, mobile Safari doesn't seem to comply with the Page Visibility API when a browser tab is closed. We weren't able to see a visibilitychange === hidden event fire on tab close, which would make that scenario look like a crash.

Also considered using a Service Worker to send a heartbeat, but similarly can't think of how to remove false positives of normal tab closes.

0

There are 0 best solutions below