Closed
Bug 742376
Opened 13 years ago
Closed 12 years ago
DisableDevice is being called with types that are not known device sensors
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
FIXED
mozilla14
People
(Reporter: dougt, Assigned: dougt)
References
Details
Attachments
(2 files)
1.53 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
1017 bytes,
patch
|
smaug
:
review+
akeybl
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
We are seeing these warnings all of the time:
NS_WARNING("Disabling an unknown device sensor.");
Caused here:
http://mxr.mozilla.org/mozilla-central/source/content/events/src/nsEventListenerManager.cpp#360
The problem is that the test:
EVENT_TYPE_EQUALS(ls, aType, aUserType)
Is false, and we never increment typeCount.
We drop out of that loop, and call DisableDevice on whatever type is passed in.
Assignee | ||
Comment 1•13 years ago
|
||
Assignee: nobody → doug.turner
Attachment #612198 -
Flags: review?(bugs)
Comment 2•13 years ago
|
||
Comment on attachment 612198 [details] [diff] [review]
patch v.1
># HG changeset patch
># Parent 087971d348c7b8e002f9695ccbc4871dc2044537
># User Doug Turner <dougt@dougt.org>
>Bug 742376 - DisableDevice is being called with types that are not known device sensors. r=smaug
>
>diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp
>--- a/content/events/src/nsEventListenerManager.cpp
>+++ b/content/events/src/nsEventListenerManager.cpp
>@@ -372,38 +372,39 @@ nsEventListenerManager::RemoveEventListe
> return;
> }
>
> nsListenerStruct* ls;
> aFlags &= ~NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
>
> PRUint32 count = mListeners.Length();
> PRUint32 typeCount = 0;
>+ bool deviceType = IsDeviceType(aType);
>
> for (PRUint32 i = 0; i < count; ++i) {
> ls = &mListeners.ElementAt(i);
> if (EVENT_TYPE_EQUALS(ls, aType, aUserType)) {
> ++typeCount;
> if (ls->mListener == aListener &&
> (ls->mFlags & ~NS_PRIV_EVENT_UNTRUSTED_PERMITTED) == aFlags) {
> nsRefPtr<nsEventListenerManager> kungFuDeathGrip = this;
> mListeners.RemoveElementAt(i);
> --count;
> mNoListenerForEvent = NS_EVENT_TYPE_NULL;
> mNoListenerForEventAtom = nsnull;
>
>- if (!IsDeviceType(aType)) {
>+ if (deviceType) {
> return;
> }
> --typeCount;
> }
> }
> }
>
>- if (typeCount == 0) {
>+ if (deviceType && typeCount == 0) {
> DisableDevice(aType);
> }
> }
>
> static inline bool
> ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent)
> {
> // This is slightly different from EVENT_TYPE_EQUALS in that it returns
Attachment #612198 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 3•13 years ago
|
||
Comment 5•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla14
Comment on attachment 612198 [details] [diff] [review]
patch v.1
Review of attachment 612198 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/events/src/nsEventListenerManager.cpp
@@ +395,2 @@
> return;
> }
You flipped this conditional around. How exactly do we ever get into DisableDevice now?
Assignee | ||
Comment 7•13 years ago
|
||
when count == 0. Maybe I am not understanding what you are asking.
Comment 8•13 years ago
|
||
Bug there is this even before
>+ if (deviceType) {
> return;
> }
Assignee | ||
Comment 9•12 years ago
|
||
yeah, i don't recall what the early return was about.
Comment 10•12 years ago
|
||
The early return (if it was !deviceType) would be for performance.
Assignee | ||
Comment 11•12 years ago
|
||
I think it was something like if we had two event listeners for a sensor and one event event listener was removed, we'd end up calling DisableDevice. So, we have the early return to prevent that. Reading the code, i think we can just remove that early return all together.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 12•12 years ago
|
||
Then we'd iterate all the listeners always.
Assignee | ||
Comment 13•12 years ago
|
||
don't we do that for every other event type?
Comment 14•12 years ago
|
||
Eh, what? No. At least we didn't used to.
if (deviceType) {
return;
}
should be
if (!deviceType) {
return;
}
right?
Assignee | ||
Comment 15•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Attachment #628511 -
Flags: review?(bugs)
Comment 16•12 years ago
|
||
Comment on attachment 628511 [details] [diff] [review]
follow to fix logic
Is it possible the add some tests to check that we end up actually
disabling some devices?
Attachment #628511 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 17•12 years ago
|
||
yes, great suggestion.
Assignee | ||
Comment 18•12 years ago
|
||
see bug 759989.
Assignee | ||
Comment 19•12 years ago
|
||
Comment 20•12 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 13 years ago → 12 years ago
Resolution: --- → FIXED
Comment 21•12 years ago
|
||
Doug, do we want this to branches?
Assignee | ||
Comment 22•12 years ago
|
||
Comment on attachment 628511 [details] [diff] [review]
follow to fix logic
we need this or devices may not be shutdown after use.
Attachment #628511 -
Flags: approval-mozilla-aurora?
Comment 23•12 years ago
|
||
Comment on attachment 628511 [details] [diff] [review]
follow to fix logic
Looks low risk and we're early in the cycle - let's get this on Aurora 15 as soon as possible.
Attachment #628511 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
You need to log in
before you can comment on or make changes to this bug.
Description
•