Closed Bug 1745443 Opened 2 years ago Closed 2 years ago

Keep alive the MIDIAccess and MIDIPort objects as long as there's pending activity

Categories

(Core :: DOM: Device Interfaces, task)

task

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: gsvelto, Assigned: gsvelto)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

My investigation in how Chrome deals with MIDI objects is down to this:

  • MIDIAccess objects are kept alive as long as they have a statechange listener and their parent execution context is alive, even if there are no other JS references to them
  • MIDIPort objects are kept alive as long as they have not been closed (that is they are open or they're in a pending state and can be opened via a MIDIConnectionEvent). This means that if there are no other JS references but a event handler/listener is present (statechange for both input and output or midimessage for input) we should still keep them alive.

Additionally we should disable the bfcache for pages using the Web MIDI API and implicitly close the ports when the user navigates away from the page using it.

This is somewhat consistent with APIs dealing with network activity (e.g. WebSocket).

MIDI ports will be kept alive even without direct JS references to it under
the following conditions:

  • They've not been explicitly closed (they're open or waiting to be)
  • A statechange listener is present
  • A midimessage listener is present for input ports only
  • They've not been disconnected from their owner, when they are we implicitly
    close them

MIDI access objects will be kept alive even without direct JS references to it
under the following conditions:

  • A statechange listener is present
  • They've not been disconnected from their owner

Finally whenever a MIDI port is in use we disable the bfcache on the
document.

Assignee: nobody → gsvelto
Status: NEW → ASSIGNED
Pushed by gsvelto@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b0941225b4ed
Keep MIDI objects alive as long as there's some pending activity r=smaug
Blocks: 1746935
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: