Re-subscribe listeners after a back-forward cache restore - #152
Open
hhunaid wants to merge 1 commit into
Open
Conversation
WebKit reuses the document on a bfcache restore without re-running the page's scripts, so median://events/subscribe is never re-sent and every listener on the page goes dead. Re-subscribe on pageshow with persisted.
kevzbldai
self-requested a review
July 30, 2026 00:37
kevzbldai
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When iOS clears event subscriptions on
didCommitNavigation, a back-forward restore that reuses the document re-clears them - but the page's scripts don't re-run, so nothing callsaddListeneragain, and every listener on the page dies silently.pageshowwithpersisted: trueis the one signal that fires on a bfcache restore. On it, re-sendmedian://events/subscribefor every event name that still has a registered callback.