Skip to content

Implement JsValueStore for SharedArrayBuffer and postMessage#4417

Merged
hansl merged 15 commits intoboa-dev:mainfrom
hansl:shared-array-buffer
Sep 22, 2025
Merged

Implement JsValueStore for SharedArrayBuffer and postMessage#4417
hansl merged 15 commits intoboa-dev:mainfrom
hansl:shared-array-buffer

Conversation

@hansl
Copy link
Contributor

@hansl hansl commented Sep 10, 2025

This adds support for creating a JsValueStore with a SharedArrayBuffer in it (including TypedArray pointing to a SAB), and add an implementation of postMessage that sends messages from JavaScript to a handler (normally another Boa Context).

As well as two tests;

  1. postMessage is in the same context as onMessageQueue
  2. two threads have their own context and send a message from one to the other.

Prior to this PR, `run_jobs()` would block as long as there would
be timeout jobs, even if they were in the future. A good example
is using `setInterval` would run an infinite loop in `run_jobs()`.

This PR unblock `run_jobs()` when the jobs do not need to be run
right now.

The new tests would infinite loop prior to this PR.
As well as two tests;
1. `postMessage` is in the same context as `onMessageQueue`
2. two threads have their own context and send a message from
   one to the other.
@hansl hansl requested a review from a team September 10, 2025 00:22
@codecov
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

❌ Patch coverage is 68.83117% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.37%. Comparing base (6ddc2b4) to head (bca3657).
⚠️ Report is 535 commits behind head on main.

Files with missing lines Patch % Lines
core/runtime/src/message/mod.rs 48.48% 17 Missing ⚠️
core/runtime/src/message/senders.rs 75.00% 5 Missing ⚠️
core/runtime/src/extensions.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4417      +/-   ##
==========================================
+ Coverage   47.24%   51.37%   +4.13%     
==========================================
  Files         476      504      +28     
  Lines       46892    51361    +4469     
==========================================
+ Hits        22154    26389    +4235     
- Misses      24738    24972     +234     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

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

Looks good overall! Nice work :)

@hansl hansl enabled auto-merge September 22, 2025 18:00
@hansl hansl added this pull request to the merge queue Sep 22, 2025
Merged via the queue into boa-dev:main with commit 908b764 Sep 22, 2025
16 checks passed
@hansl hansl deleted the shared-array-buffer branch September 22, 2025 18:22
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