Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload or recreate web view when its process is terminated #187

Merged
merged 6 commits into from
Mar 5, 2024

Conversation

svara
Copy link
Contributor

@svara svara commented Mar 1, 2024

This PR improves handling of the terminated web view processes which leave the web views with a white screen.

@zoejessica did a thorough investigation on this topic. The following is taken from one of our PRs at 37signals.

You can read more here, but tl;dr we suspect that there are three ways web views can become blank, either:

  1. they are killed in the "normal" way in the background through memory pressure, the delegate method fires, and they can then be reloaded, or
  2. they are killed by the system without triggering a delegate callback, but can be recovered with a reload, or
  3. they are killed by the system in a way that leaves them non-recoverable with a reload.

This PR takes care of all three cases.

TurboNavigator needs to track the app's state (active or background) in order to decide when to reload the terminated web views. To facilitate this, I've added two public functions: appDidBecomeActive() and appDidEnterBackground().

Copy link
Member

@joemasilotti joemasilotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMAZING! So excited for this one.

First two comments are more suggestions, feel free to ignore them if you don't agree.

But I think we need to address the last one at the end of the PR. Unless I'm missing something.

Lastly, if I have two tabs open they both seem to reload at the same time when triggering a killed web view.

Source/Turbo Navigator/TurboNavigator.swift Outdated Show resolved Hide resolved
Source/Turbo Navigator/TurboNavigator.swift Outdated Show resolved Hide resolved
Source/Turbo Navigator/TurboNavigator.swift Show resolved Hide resolved
@svara svara requested a review from joemasilotti March 4, 2024 16:49
Copy link
Member

@joemasilotti joemasilotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I made one small request of moving where the internal function lives. But feel fine merging either way.

Source/Turbo Navigator/TurboNavigator.swift Outdated Show resolved Hide resolved
@svara svara merged commit 6590418 into turbo-navigator Mar 5, 2024
1 check passed
@svara svara deleted the blank-webview branch March 5, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants