Open Bug 1564880 Opened 3 years ago Updated 1 month ago

Run StructuredDeserialize lazily

Categories

(Core :: DOM: postMessage, enhancement)

enhancement
Not set
normal

Tracking

()

People

(Reporter: surma, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36

Steps to reproduce:

  1. Send a big message from a worker to the main thread using postMessage()
  2. Measure the time it takes to access the MessageEvent’s .data property

Demo: https://postmessage-benchybench.glitch.me/lazy-deserialize.html
Code: https://glitch.com/edit/#!/postmessage-benchybench?path=lazy-deserialize.html

Actual results:

It takes almost no time.

Expected results:

It should take some time (I’m seeing between 20 and 40ms on a MacBook Pro). Chrome and Safari seem to run StructuredDeserialize1 lazily, so only once .data is being accessed.

I think this is desirable as it puts the developer in control when to pay the performance hit of deserializing potentially big payloads. It also aligns Firefox with Chrome and Safari.

I tested this on Mac OS X 10.14 with FF Release 68 and Nightly 70.0a1(2019-07-14) and I have the same result like the one from the reporter. I'm not sure if this should be marked as an enhancement or a defect, for the moment I will mark it as an enhancement but please feel free to change it if you consider it necessary.

Status: UNCONFIRMED → NEW
Type: defect → enhancement
Component: Untriaged → Networking
Ever confirmed: true
Product: Firefox → Core
Version: 68 Branch → Trunk
Component: Networking → JavaScript Engine
Component: JavaScript Engine → DOM: Core & HTML
Blocks: 1254240
No longer depends on: 1254240
Component: DOM: Core & HTML → DOM: postMessage
You need to log in before you can comment on or make changes to this bug.