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

Ensure that a snapshot is cached before navigating to a new location #303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jayohms
Copy link
Collaborator

@jayohms jayohms commented Feb 23, 2024

This is the Android counterpart to: hotwired/turbo-ios#181

Prior to this PR it was possible that a snapshot was not cached for a given page when navigating away from a WebView screen. Replication steps:

  1. Visit native screen A
  2. Navigate to web screen B
  3. Dismiss web screen B and navigate back to the native screen A
  4. Navigate to web screen B again. There was no snapshot cache available.

This is due to the fact that, historically, snapshots were only cached by core turbo.js when navigating from web -> web screens. This resolves the issue by always caching a snapshot before navigating away from a web screen.

@pfeiffer
Copy link

Looks great!

In the hotwired/turbo-ios#181 I added a delegate method to deactivate the Visitable when the VisitableView did disappear; the thought was that we could end up with an active, but orphaned Visitable for the session, eg. when a modal is dismissed, it's WebView would still stay active, potentially receiving Turbo Streams etc. in the background, which feels off. We'd rather prepare the screenshot until next visit in that session.

Is there a similar need for such a thing in the Android library? TBH I'm not that familiar with the Turbo Android implementation, as we've primarily re-implemented most of it in the React Native Turbo library due to TurboSession marked as private.

@jayohms
Copy link
Collaborator Author

jayohms commented Feb 23, 2024

There shouldn't be any similar concerns in the Android library, since the WebView already gets properly detached/deactivated before navigating away from a Fragment. And, the Android library does not use separate modal vs default sessions like iOS, so there aren't the same concerns there, either.

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