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

Cache snapshot before doing page refresh #1188

Closed

Conversation

pfeiffer
Copy link
Contributor

This PR aims to fix issues related to white flickering and loading indicators on Turbo Native:

Previously, any refresh visit would exempt itself from the snapshot cache before issuing a visit(..., action: "replace"). In a browser, this keeps the existing body in-place while refreshing the page and then performing morphing. The visit would have hasSnapshot: false.

In Turbo Native, when a visit is performed without a snapshot, a spinner will be shown and in some cases the WebView will be blanked as well while the page is fetched. This is especially painful when refresh stream actions are broadcasted, as the WebView will at random become unresponsible and/or flickr.

This PR changes so that a snapshot of the page is cached before issuing a refreshing visit. The cached snapshot will be of the recent state of the page and the native adapters will not blank the page while fetching the refreshed page.

I think it makes sense that page refreshes are storing the latest version of the page as a snapshot before refreshing; it is the most recent version of the content.

@pfeiffer
Copy link
Contributor Author

This is how a refresh visit behaves in the native apps today:

MorphBefore.mov

With the changes in this PR:

TurboReplaceMorphing.mov

Ultimately, the native apps will still show a short flash of white content, as they are swapping out the WebView for a snapshot. To fix this I believe that the changes proposed in #1186 is needed so that the native adapters would be able to distinguish refresh actions.

@jayohms
Copy link
Collaborator

jayohms commented Feb 23, 2024

@pfeiffer can this be closed now that hotwired/turbo-ios#178 has been merged?

@pfeiffer
Copy link
Contributor Author

Closing as not relevant.

@pfeiffer pfeiffer closed this Feb 23, 2024
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