Closed Bug 1753131 Opened 3 years ago Closed 3 years ago

Dispatch devicechange events even without an actively capturing MediaStreamTrack

Categories

(Core :: WebRTC: Audio/Video, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
98 Branch
Tracking Status
firefox98 --- fixed

People

(Reporter: karlt, Assigned: karlt)

References

Details

Attachments

(8 files)

+++ This bug was initially created as a clone of Bug #1732409 +++

Gecko currently dispatches "devicechange" events only when

  1. there is an actively capturing MediaStreamTrack, or
  2. the origin has a permission for permanent access to a camera or microphone.

"fully active and has focus" has subsequently been added to the spec as a sufficient condition. This provides for "audiooutput" devices even when getUserMedia() is not used.

The permissions check was replaced in the spec with a [[canExposeDeviceInfo]] MediaDevices slot, set on getUserMedia() grant.
This makes the actively capturing test redundant as a track cannot become active without a getUserMedia() grant.

Removing the actively capturing test will resolve a defect where actively capturing tracks can be prematurely GC'd causing loss of "devicechange" events.

With provision of "devicechange" events in more circumstances, we should only add events for devices that should be exposed.

"User Agents MAY add fuzzing on the timing of events to avoid cross-origin activity correlation."
Waiting for focus before dispatch would provide the best protection against cross-origin activity correlation. With the plan to wait for focus in enumerateDevices(), there would be little value in dispatching "devicechange" before enumerateDevices() could proceed.

Assignee: nobody → karlt
Status: NEW → ASSIGNED

There is a chance that this may result in some associated events no longer
being coalesced into a single devicechange event, but there is little
disadvantage to this while there is an advantage to getting devicechange
events promptly.

Future changes for https://bugzilla.mozilla.org/show_bug.cgi?id=1732409 will
track exactly which devices have changed and so filter out no-op
notifications.

Depends on D132892

Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bab7826f0f12 use MediaManager device list change coalescing for MediaDevices r=jib

The same list of physical devices can, in a subsequent patch, be returned to
multiple Windows, so that their MediaDevices objects can efficiently keep (and
share) a record of the set of devices when the last "devicechange" event was
queued.

"media.ondevicechange.fakeDeviceChangeEvent.enabled" does not change any
devices and so will not generate any events if/when no-op devicechange events
are filtered out.

The test is rearranged to reduce the wait for no event and run some steps in
parallel, so that the test runs in half the time. This benefit will
accumulate as more scenarios are added to the test.

There was little value in dispatching devicechange before enumerateDevices
could proceed.

"fully active and has focus" is now a sufficient condition for dispatching "devicechange" events if the change in devices should be visible from enumerateDevices().
https://github.com/w3c/mediacapture-main/pull/574/files#diff-1217ca1c44ff30a33dd50c49d03b5cadc9633c789df8ff9370ed4a42859e1211R3146

Permissions checks are replaced with [[canExposeCameraInfo]] and [[canExposeMicrophoneInfo]] slots set by getUserMedia().
https://github.com/w3c/mediacapture-main/pull/641
https://github.com/w3c/mediacapture-main/pull/773

The "media.navigator.permission.disabled" pref is no longer involved in "devicechange" dispatch decisions.

Attachment #9261819 - Attachment description: provide a method to return a cached list of physical devices → Bug 1753131 provide a method to return a cached list of physical devices
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/832332286dae provide a method to return a cached list of physical devices r=jib https://hg.mozilla.org/integration/autoland/rev/eb741033c48d use fake device name changes to test devicechange events r=jib
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/674481a62e49 wait for focus before dispatching devicechange events r=jib
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2bd8cb6b8d67 Dispatch devicechange events even without an actively capturing MediaStreamTrack r=jib
Keywords: leave-open
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d1892e5545d1 test devicechange events when first device is added or last is removed r=jib https://hg.mozilla.org/integration/autoland/rev/e014a0fdfa90 test that devicechange event is fired even when hardware changes continue r=jib https://hg.mozilla.org/integration/autoland/rev/f6b4c4d797f3 test "devicechange" event with different exposure timing r=jib
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: