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

perf: Encode messages in mobile as byte arrays #3077

Merged
merged 4 commits into from
Feb 12, 2025

Conversation

FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Feb 7, 2025

Base64 encoding/decoding seems to be a significant overhead for the boot message on mobile. Encoding the messages as bytes instead have proven to be more performant, but still has overhead.

@FrederikBolding FrederikBolding changed the title perf: Stop using additional encoding for messages in mobile perf: Stop encode messages in mobile as byte arrays Feb 11, 2025
@FrederikBolding FrederikBolding changed the title perf: Stop encode messages in mobile as byte arrays perf: Encode messages in mobile as byte arrays Feb 11, 2025
@FrederikBolding FrederikBolding marked this pull request as ready for review February 11, 2025 16:04
@FrederikBolding FrederikBolding requested a review from a team as a code owner February 11, 2025 16:04
@@ -22,12 +22,12 @@ describe('WebViewMessageStream', () => {
expect(await responsePromise).toBe(555);

expect(mockWebViewA.injectJavaScript).toHaveBeenCalledWith(
`window.postMessage('eyJ0YXJnZXQiOiJiIiwiZGF0YSI6MTExfQ==')`,
`window.postMessage([123,34,116,97,114,103,101,116,34,58,34,98,34,44,34,100,97,116,97,34,58,34,83,89,78,34,125])`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the size increase not of concern? Does this work with very large Snap bundles etc.?

Copy link
Member Author

@FrederikBolding FrederikBolding Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually posting the message is slightly slower yes, but we save a lot of time encoding/decoding. Seems worth it even with the size increase.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.88%. Comparing base (81db94d) to head (7c7c37b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3077      +/-   ##
==========================================
- Coverage   94.88%   94.88%   -0.01%     
==========================================
  Files         506      506              
  Lines       11121    11120       -1     
  Branches     1708     1708              
==========================================
- Hits        10552    10551       -1     
  Misses        569      569              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@FrederikBolding FrederikBolding merged commit cec343a into main Feb 12, 2025
166 checks passed
@FrederikBolding FrederikBolding deleted the fb/mobile-perf-pass branch February 12, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants