Closed
Bug 1845633
Opened 1 year ago
Closed 1 year ago
DisableDevice logic is probably broken for once listeners
Categories
(Core :: DOM: Events, defect, P3)
Core
DOM: Events
Tracking
()
RESOLVED
FIXED
118 Branch
People
(Reporter: mstange, Assigned: mstange)
References
Details
In EventListenerManager, EnableDevice / DisableDevice need to be called once for each added/removed event listener (if it matches a certain list of event types).
nsGlobalWindowInner::EnableDeviceSensor
counts the numbers of calls and expects them to be properly balanced.
EventListenerManager does this correctly for calls to AddEventListener / RemoveEventListener and SetHandler.
But for "once" listeners, we only call DisableDevice if we have no remaining listeners of that type. I'm pretty sure this is wrong - we need to call it once per removed "once" listener.
if (IsDeviceType(aEvent->mMessage)) {
// This is a device-type event, we need to check whether we can
// disable device after removing the once listeners.
const auto [begin, end] = mListeners.NonObservingRange();
const bool hasAnyListener =
std::any_of(begin, end, [aEvent](const Listener& listenerRef) {
const Listener* listener = &listenerRef;
return EVENT_TYPE_EQUALS(listener, aEvent->mMessage,
aEvent->mSpecifiedEventType,
/* all events */ false);
});
if (!hasAnyListener) {
DisableDevice(aEvent->mMessage);
}
}
The impact of this is that we may waste some power under certain conditions, by listening for device orientation / proximity / light changes unnecessarily.
Updated•1 year ago
|
Severity: -- → S3
Priority: -- → P3
Assignee | ||
Updated•1 year ago
|
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
status-firefox116:
--- → wontfix
status-firefox117:
--- → wontfix
status-firefox118:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•