Skip to content

[0.83] Pick WebSocket queue size fix for Android inspector#56807

Open
huntie wants to merge 3 commits into
facebook:0.83-stablefrom
huntie:android-inspector-websocket-queue-fix
Open

[0.83] Pick WebSocket queue size fix for Android inspector#56807
huntie wants to merge 3 commits into
facebook:0.83-stablefrom
huntie:android-inspector-websocket-queue-fix

Conversation

@huntie
Copy link
Copy Markdown
Member

@huntie huntie commented May 13, 2026

Summary

Picks #54300 (+ follow-ups) to 0.83-stable.

Establishes a queue mechanism on top of OkHttp's WebSocket implementation for the Android inspector packager connection. This controls the queue size and guarantees that no more than 16 MiB is scheduled at once, preventing OkHttp from force-closing the WebSocket connection when the threshold is exceeded.

Changelog:

[Android] [Fixed] - Limit WebSocket queue size for packager connection

Test plan

  • Verified cherry-picks apply cleanly on top of 0.83-stable.
  • Existing test coverage in CxxInspectorPackagerConnectionTest.kt.

hoxyq added 3 commits May 13, 2026 14:22
Summary:
Pull Request resolved: facebook#54300

Establishes a queue mechanism on top of the OkHttp's WebSocket implementation. This mechanism will control the queue size and guarantee that we don't have more than 16MB scheduled.

This prevents the scenario of when OkHttp forces WS disconnection because of this threshold.

Reviewed By: motiz88, alanleedev

Differential Revision: D85581509

fbshipit-source-id: ac3e830c935c1301b674739c96fcbe18446eaa71
Summary:
Pull Request resolved: facebook#54301

# Changelog: [Internal]

Previously, we would read every single kilobyte and do Java -> C++ call with `jni`.

For big objects, like source maps, this means that we were doing at least 1024 calls for a single megabyte of incoming data. From my observations, some source maps on Twilight could reach 30Mb+.

There is a trade-off between how much of memory we want to allocate while reading a stream and a runtime. I didn't notice any differences while changing the chunk size from 8Kb to 1Mb and some values in between; in the end it purely depends on the OkHttp's or Okio's implementation of the stream, looks like it uses 8Kb as a chunk size by default:
{F1983042734}

Reviewed By: huntie

Differential Revision: D85652217

fbshipit-source-id: 68474f0b7eece13a0a1c8ea9e617b99a26d81ff9
Summary:
Pull Request resolved: facebook#54352

# Changelog: [Internal]

Since we can now avoid disconnections, it should be safe to increase the chunk size.

This should improve the trace loading time.

Reviewed By: huntie

Differential Revision: D85937959

fbshipit-source-id: 4f0ef023a4d756217de0c756dbc1decbd99698d4
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 13, 2026
@huntie huntie changed the title Cherry-pick WebSocket queue size fix for Android inspector [0.83] Pick WebSocket queue size fix for Android inspector May 13, 2026
@huntie huntie marked this pull request as ready for review May 13, 2026 13:27
@github-actions
Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: BREAKING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner Pick Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants