v134 · offline / storage

Support Web Locks API in Shared Storage

Today, concurrent execution of shared storage worklets in scenarios like cross-site reach measurement can result in duplicate reporting, due to the potential race conditions within the "get() and set()" logic. To address this issue, we propose integrating the Web Locks API into Shared Storage. Specifically, - Introduce navigator.locks.request to the work

concepts

  1. Shared Storage + Web Locks

    Shared Storage operations can acquire Web Locks. Coordinates writes from multiple worklets without races.

  2. Dedupe reach measurement

    The named motivating race: five worklets seeing reported=false at once and all reporting. Run the race with and without locks side by side.

  3. Race Replayer

    Per-worklet timeline of get/set/report ops with and without Web Locks; duplicate-report counter shows the inflation.

  4. Lock Contention Probe

    Run N concurrent worklet-shaped tasks against a shared "seen" flag. The lock path uses real navigator.locks.request(); duplicate-report counter shows the race condition eliminated.

why it shipped

Today, concurrent execution of shared storage worklets in scenarios like cross-site reach measurement can result in duplicate reporting, due to the potential race conditions within the "get() and set()" logic. To address this issue, we propose integrating the Web Locks API into Shared Storage. Specifically, - Introduce navigator.locks.request to the work

references