Commit 84ce4d0
committed
[2.x] fix(realtime): only force-reconnect on iOS visibilitychange
PR #4654 added a `visibilitychange` listener that forces a fresh
Pusher instance and refreshes the visible discussion list whenever
the tab has been hidden for >5s. That was needed on iOS Safari,
where backgrounding the page silently drops the WebSocket without
firing `close`. On every other platform the WebSocket survives tab
backgrounding fine — but the visibilitychange handler still fired,
causing an unnecessary `GET /api/discussions` request and full list
re-render every time the user switched away and back.
Gate the visibilitychange-triggered `forceReconnect()` on `isIOS()`
so the workaround only runs on the platform that actually needs it.
The `pageshow(persisted=true)` path stays unconditional — bfcache
restoration only fires on browsers that bfcached the page, and the
WebSocket was definitely torn down by then regardless of platform.
`isIOS()` is broader than the existing `isSafariMobile()` core
utility because all iOS browsers use WebKit and share the same
backgrounding pathology — iOS Chrome (`CriOS`) and iOS Firefox
(`FxiOS`) are excluded by `isSafariMobile()` but still need this
workaround.
Regression from #4654.1 parent e5f3705 commit 84ce4d0
2 files changed
Lines changed: 35 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
| |||
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
137 | | - | |
| 143 | + | |
138 | 144 | | |
139 | 145 | | |
140 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments