GeezerVison is showing github.com — fix(mobile): iOS app gets compressed websocket frames by only21mil · Pull Request #24931 · pingdotgg/t3code
Conversation
only21mil
commented
Oct 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Problem
The iOS app downloads every WebSocket frame uncompressed (#21183). The server has negotiated permessage-deflate since #4705, but only when the client offers it. On iOS the runtime uses React Native's global WebSocket, SocketRocket, which never sends Sec-WebSocket-Extensions. Android (OkHttp) and desktop (Chromium) offer it. The reporter measured the same providerStatuses push at 558 KB to an iPhone and 141 KB to desktop.
Change
iOS now opens the app's WebSocket with URLSessionWebSocketTask, which offers permessage-deflate in its handshake.
apps/mobile/modules/t3-websocket: an Apple-only Expo module with connect, sendText, sendBinary and close, and events keyed by a JS-assigned id. The session skips registered URLProtocol classes, since dev clients install ones that drop the socket after the 101. The receive limit is raised from URLSession's 1 MB default to 128 MB because thread snapshots can be larger. A task that ends without a close frame reports 1006, as browsers do, so the connection supervisor reconnects. One that ends cleanly without didCloseWith reports 1005, so the JS socket never sticks in CLOSING.
apps/mobile/src/lib/nativeWebSocket.ts: a Socket.WebSocketLike over that module, provided as the mobile runtime's WebSocketConstructor. A native open that arrives after close() is ignored, so an open timeout can't revive a dropped socket. The layer subscribes to native events when built and unsubscribes when released. Socket ids keep counting across Fast Refresh, so a late close from an older URLSession task can't close a newer socket.
apps/mobile/src/lib/runtime.ts: uses that layer in place of Socket.layerWebSocketConstructorGlobal.
Android has no T3WebSocket native module, and neither do iOS binaries built before this change, so both keep the global WebSocket unchanged. The constructor takes only a URL and subprotocols, which is all its two callers pass, and throws on other options rather than dropping them.
Scope and approval
Fixes #21183. A maintainer's triage comment asked for an iOS capture of the upgrade request, and the reporter supplied it. #4794 was closed on the reading that #4705 covered it, but #4705 is the server half. There is no maintainer agreement on this approach yet. The choice for maintainers to confirm is a small app-owned native module for the main socket rather than a third-party WebSocket library. This awaits maintainer review.
Out of scope: the preview and device-stream sockets in client-runtime still use the global WebSocket.
Verification
protectedData.test.ts, which builds the real mobile runtime, gains a check that iOS dials through T3WebSocket. On main it fails at its assertion because the runtime hands iOS the global WebSocket. Its expo mock now answers per module name.
nativeWebSocket.test.ts, 4 tests: text and binary round trip, server close codes, a late native open, and an old socket's close arriving after Fast Refresh opened its replacement.
- Every mobile test file that imports or mocks
lib/runtime or the new module passes: those two plus connection, storage, preferences, pending-task-editor-writes, queued-run-edit, thread-outbox-removal, CloudAuthProvider, remoteRegistration, AddProjectScreen, thread-settings-sheet-state and app-updates.
vp run typecheck in apps/mobile, plus vp fmt --check and vp lint on the changed files: clean.
- iOS 26.5 simulator, Debug builds of main and this branch's first commit (the second changes no native code), each paired to a local server. tcpdump on the loopback port recorded the
/ws upgrade, query string dropped. On main the app's request has no Sec-WebSocket-Extensions and the 101 carries none. On this branch the request offers permessage-deflate and the 101 accepts it.
- On this branch the app sent a message over the new socket and the server's events came back on it. The provider error is expected: the test server had no provider.
Not checked:
- A physical iPhone, or a Release build.
- Bytes on the wire. The test server had almost no data, so the size difference is the reporter's measurement.
wss through T3 Connect or a reverse proxy, network changes, backgrounding, and frames over 1 MB.
- Android on a device. Its path is unchanged: the module is Apple-only and the layer checks
Platform.OS.
Prior PRs
The upgrade headers the server saw from the iOS app on main (SocketRocket) and on this branch (URLSession).

This branch on the iOS simulator: a message sent over the new socket, and the server's reply events back on it.

The new runtime test on main: the iOS runtime dials through the global WebSocket.

The runtime test and the adapter tests passing on this branch.

Generated with Claude Opus 5.5 in T3 Code Nightly
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
React Native's iOS WebSocket is SocketRocket, which never offers
permessage-deflate, so the server sent every frame to iPhones
uncompressed. Android's OkHttp socket and desktop already negotiate it.
Add an Apple-only Expo module backed by URLSessionWebSocketTask, which
offers the extension in its handshake, and provide it as the mobile
runtime's WebSocketConstructor on iOS. Android and iOS binaries built
before the module keep the global WebSocket.
Based on an earlier closed change by t3dotgg.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The iOS WebSocket constructor now subscribes to native events when its
layer is built and removes them, closing any sockets it still owns, when
the layer is released. Importing the module does no native work.
Socket ids keep counting across module evaluations, so a late event from
a URLSession task started before Fast Refresh cannot reach, or close, a
socket opened after it.
The protected storage test mocked every native module with the native
controls stub. It now answers per module name, and a new test checks
that the iOS runtime dials through the native module instead of the
global WebSocket.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Approvability
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — This PR adds a new iOS-native WebSocket stack and makes it the default transport for the mobile runtime, affecting production connection lifecycle and native build integration. The scope is broader than a self-contained bug fix and warrants maintainer review.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Oct 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between e72a884 and 5318f29.
Files selected for processing: 3
-
apps/mobile/src/lib/nativeWebSocket.test.ts
apps/mobile/src/lib/nativeWebSocket.ts
apps/mobile/src/lib/protectedData.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Walkthrough
-
The PR adds an iOS Expo WebSocket module backed by URLSessionWebSocketTask and an Effect adapter. The runtime selects the native constructor when the module is available. Tests cover adapter behavior and runtime selection.
Changes: iOS WebSocket
| Layer / File(s) |
Summary |
Native WebSocket transport apps/mobile/modules/t3-websocket/expo-module.config.json, apps/mobile/modules/t3-websocket/ios/T3WebSocket.podspec, apps/mobile/modules/t3-websocket/ios/T3WebSocketModule.swift |
Registers the Apple Expo module. The module manages URLSessionWebSocketTask connections, sends and receives text and binary messages, and emits connection events. |
Effect adapter and runtime integration apps/mobile/src/lib/nativeWebSocket.ts, apps/mobile/src/lib/runtime.ts, apps/mobile/src/lib/nativeWebSocket.test.ts, apps/mobile/src/lib/protectedData.test.ts |
Adds an Effect adapter that routes native events and binary messages. The runtime selects the adapter when the native module is available. Tests cover adapter behavior and runtime selection. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)
sequenceDiagram
participant Runtime
participant NativeWebSocket
participant T3WebSocketModule
participant URLSessionWebSocketTask
Runtime->>NativeWebSocket: Create socket with URL and protocols
NativeWebSocket->>T3WebSocketModule: Connect with socket ID, URL, and protocols
T3WebSocketModule->>URLSessionWebSocketTask: Resume connection
URLSessionWebSocketTask-->>T3WebSocketModule: Deliver open, message, or close callback
T3WebSocketModule-->>NativeWebSocket: Emit event with socket ID
NativeWebSocket-->>Runtime: Dispatch WebSocket event
Loading
Suggested labels: bugfix, 📱 Native Change
Suggested reviewers: nekohasekai, juliusmarminge
Merge Risk: Minimal · up to 5318f
-
No actionable issue is established for the iOS main-socket change; it is mergeable after normal checks.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title clearly identifies the main change: enabling compressed WebSocket frames in the iOS mobile app. |
| Linked Issues check |
 |
Issue #21183 requires the iOS app's main WebSocket to offer permessage-deflate and receive compressed frames. The PR adds the Apple-only T3WebSocket module with URLSessionWebSocketTask, wires it… |
| Out of Scope Changes check |
 |
The supplied change summary limits changes to the native WebSocket module, its Effect WebSocketLike adapter, runtime wiring, and related tests. These changes support issue #21183. The PR leaves prev… |
| Description check |
 |
The description follows the required template. It explains the problem, implementation, scope, verification results, limitations, linked issue, screenshots, and agent model and harness. It also clearl… |
Full details: Linked Issues check
-
Explanation
Issue #21183 requires the iOS app's main WebSocket to offer permessage-deflate and receive compressed frames. The PR adds the Apple-only T3WebSocket module with URLSessionWebSocketTask, wires it into the mobile runtime, and retains the global WebSocket fallback for Android and older iOS binaries. The reported iOS simulator capture shows the request offering permessage-deflate and the server accepting it. Tests cover iOS runtime selection, text and binary frames, close handling, late open handling, and Fast Refresh socket replacement. The repository diff was unavailable for the current incremental comparison, so this conclusion uses the supplied PR summary and previous reviewed evidence.
Full details: Out of Scope Changes check
-
Explanation
The supplied change summary limits changes to the native WebSocket module, its Effect WebSocketLike adapter, runtime wiring, and related tests. These changes support issue #21183. The PR leaves preview and device-stream sockets in client-runtime unchanged, as required by the stated scope. No unrelated change is established. The repository diff was unavailable for the current incremental comparison, so this conclusion uses the supplied PR summary and previous reviewed evidence.
Full details: Description check
-
Explanation
The description follows the required template. It explains the problem, implementation, scope, verification results, limitations, linked issue, screenshots, and agent model and harness. It also clearly states that maintainer approval for the proposed approach is still pending.
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note Written by gpt-6.1-sol on behalf of Maria
updated this branch directly, preserving @only21mil's commits and merging current main (e762f09e265b). the original URLSession transport, native registration, fallback, and fast refresh design remain intact. no replacement pr or unrelated changes.
added one production line: discard queued native messages once the socket leaves OPEN. a new regression in the existing adapter test failed before that guard and passes with it. added checks for layer teardown removing listeners and closing sockets, plus android and older-ios global-socket fallback. two independent reviews approved head 5318f29b5d45d48168d2a27638be598fae38b2ff without remaining findings.
verification on blacksmith:
- current main fails the existing ios routing assertion because it calls the global websocket constructor.
- the candidate passes all 12 focused tests: routing/fallback, text/binary round trip, server close, late open, stale message, teardown, fast refresh, and protected-storage startup.
vp run check:changed passes format, lint, both knip checks, mobile/scripts typecheck, and the two affected test files.
unverified: native ios compilation and actual compression negotiation, physical-device/release behavior, background/resume, network changes, proxy/T3 Connect, and large frames. this linux vm has no apple runtime. the original author's simulator captures remain author-reported evidence. no UI behavior or layout changed, so browser captures would not verify this transport.
maintainer approval is still needed for making the app-owned native transport the ios default. before merging, exercise the native app through background/resume and a network interruption, confirm reconnection delivers a new message, and check the negotiated extension on its /ws upgrade. preview/device-stream sockets remain outside this fix, as in the original.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note Written by gpt-6.1-sol on behalf of Maria
Verified in a real dev environment
disposition: unverifiable for the ios fix on this linux vm. these checks cover neighboring web behavior, not the changed native transport.
read the description, full diff, discussion, review comments, commit authors, and checks. the pr is open, with no commits by @juliusmarminge or @t3dotgg. checked exact head 5318f29b5d45d48168d2a27638be598fae38b2ff without changing it.
- installed and ran
github/main (48a292364ab37574c67fb377b5227e5d281d9203) in /home/user/main, then stopped its captured server pid before starting the pr. installed the exact pr head and ran it with explicit isolated state: vp run dev --home-dir /home/user/t3code/.t3.
- drove the actual web app with repository playwright and
/usr/bin/google-chrome. added a project pointing at the real /home/user/main git repo, created a thread, selected codex gpt-6.1-sol, and submitted the same prompt on both revisions. both returned transport verification ok through the real local provider proxy. no mocks, fixtures, or demo data.
- on the pr, reloaded the client and saw persisted history. a fresh
/ws upgrade returned 101, offering permessage-deflate; client_max_window_bits and accepting permessage-deflate. the web path also negotiated compression on main.
- after browser offline/online, sent a follow-up in the same thread and received
reconnect verification ok. this does not establish that an underlying tcp connection dropped, or prove native reconnection.
- inspected the exported clip, checked uploaded playback to the end and seeking in the t3 browser player, and verified the uploaded transcript. existing head checks are green where run; native preview and some deploy checks were skipped. no new source changes or check:changed run in this verification pass.
command and handshake transcript

Not verified
the original ios bug could not be reproduced on main, and the changed ios behavior could not be exercised here. this linux x86_64 vm has no apple sdk, xcodebuild, swift toolchain, or native ios client. chrome uses its own websocket transport and never executes T3WebSocketModule.swift or the mobile runtime selection. a successful browser turn is therefore insufficient evidence for this fix.
still required on an apple host: build and pair the native app on main and this head; capture the actual /ws upgrade; confirm the main app does not offer compression and the pr does; run a real provider turn; exercise background/resume and a genuine connection interruption followed by another turn. native compilation, physical-device/release behavior, android and older-ios fallback, large frames, and t3 connect/proxy behavior remain unverified. no production fix was attempted without reproducing a failure in the changed path.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dbxe
commented
Oct 30, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Note 🤖 Claude Opus 5.5 responding on behalf of Daniel Briskin
I ran this on a physical iPad. It negotiates compression and cuts the streaming data about 6x, but it didn't change whole-device power over Wi-Fi.
Setup: iPad mini (A17 Pro), iPadOS 26.7.2, Release build, server reached over Tailscale. The first runs were accidentally in landscape. I re-ran the power trial in portrait to match the #27325 bench, and the numbers below are from that run. I applied this PR's diff onto dac8b11ddc, because that's where the #27325 power bench is pinned.
- Works: the app connects, opens threads and streams a replayed turn normally.
- Bytes (measured in landscape; orientation doesn't change what the server sends): during the same 120 s streaming window, the server sent 122 KB to the app, against 755 KB without this PR. I counted the Tailscale extension's bytes on the server host.
- Power: a 2-block A/B trial on the streaming phase reads −25 / +7 mW per block in portrait, inside the bench's ~25 mW resolution. The landscape run read −6 / +1.
Not checked: reconnects, background/foreground, relay and tunnel paths, and cellular. Cellular is where fewer bytes should save the most power: in a sysdiagnose power log from the same user, about half of the non-display energy is cellular radio. This bench only uses Wi-Fi.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gitcafe-production Bot
pushed a commit
that referenced
this pull request
Nov 7, 2026
React Native's iOS WebSocket is SocketRocket, which never negotiates
permessage-deflate, so every frame to an iPhone arrived uncompressed even
though the server offers compression. A large shell snapshot is 1.37 MB on the
wire that way versus 88 KB deflated.
Add a local Expo module that dials through URLSessionWebSocketTask, which
offers the extension on every handshake, and a small WebSocketLike wrapper
that Effect's socket layer uses on iOS. Each socket reports its end once with
the server's close code, writes after close are dropped like browsers do, and
disposing the layer finalizes open sockets. Older dev clients without the
module keep the global WebSocket. Android is untouched: OkHttp 4.9.2 already
sends `Sec-WebSocket-Extensions: permessage-deflate` on every handshake.
Thanks to @only21mil for #24931, which reached the same URLSession approach.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
📱 Native Change
Changes the native fingerprint; merging blocks production OTAs until a new store build ships.
size:L
100-499 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
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.
|