Closed
Bug 1101994
Opened 10 years ago
Closed 9 years ago
Way too easy to trigger LogShake
Categories
(Firefox OS Graveyard :: General, defect)
Tracking
(firefox41 fixed, b2g-master fixed)
RESOLVED
FIXED
2.2 S14 (12june)
People
(Reporter: mikehenrty, Assigned: gerard-majax)
References
Details
(Whiteboard: [systemsfe])
Attachments
(6 files, 4 obsolete files)
I keep accidentally triggering it by setting the phone down on the couch. I feel like I need to shake the phone really hard (almost as if I'm angry) before it is triggered.
Updated•10 years ago
|
Whiteboard: [systemsfe]
Assignee | ||
Comment 1•10 years ago
|
||
This is something I already noticed too, and reported to James. We should just adjust the shaking detection.
Flags: needinfo?(hobinjk)
Comment 2•10 years ago
|
||
And here I thought it was too hard to trigger!
The relevant constant is EXCITEMENT_THRESHOLD: https://mxr.mozilla.org/mozilla-central/source/b2g/components/LogShake.jsm#56
Smoothing the input acceleration with a low-pass filter may also be useful.
Flags: needinfo?(hobinjk)
Assignee | ||
Comment 3•10 years ago
|
||
Just started to write an app, https://github.com/lissyx/shakeit
This will allow us to:
- record acceleration data as csv file for analysis of movements
- experiment with new approach to detect shaking
Current, only the recorder module is implemented. My plan is to start gathering some data first.
Assignee: nobody → lissyx+mozillians
Flags: needinfo?(mhenretty)
Flags: needinfo?(hobinjk)
Assignee | ||
Comment 4•10 years ago
|
||
Resulting analysis of throwing the device on my desk
Assignee | ||
Comment 5•10 years ago
|
||
Resulting analysis of shaking my device
Reporter | ||
Comment 6•10 years ago
|
||
This is great Alex! How do the units from the graph (ie -25 - 25) translate to the units from the code (ie. THRESHOLD = 500)?
Flags: needinfo?(mhenretty)
Assignee | ||
Comment 7•10 years ago
|
||
Values are just those from the devicemotionevent, as documented here: https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent.accelerationIncludingGravity
So x, y and z are m.s^-2, the charts are just with those values. And the threshold in gecko is just the result of |acc.x * acc.x + acc.y * acc.y + acc.z * acc.z|
Comment 8•9 years ago
|
||
I added a low pass filter which requires the phone to be in movement for ~10 "ticks" before registering the shake event. Very official testing involving dropping my phone on the ground, throwing it at a couch, and silly-walking while holding it has verified that the filter functions flawlessly.
Flags: needinfo?(hobinjk)
Attachment #8613813 -
Flags: review?(mhenretty)
Attachment #8613813 -
Flags: review?(lissyx+mozillians)
Assignee | ||
Comment 9•9 years ago
|
||
(In reply to James Hobin from comment #8)
> Created attachment 8613813 [details] [diff] [review]
> bug1101994-logshake.patch
>
> I added a low pass filter which requires the phone to be in movement for ~10
> "ticks" before registering the shake event. Very official testing involving
> dropping my phone on the ground, throwing it at a couch, and silly-walking
> while holding it has verified that the filter functions flawlessly.
Nice, can you provide implementation and results on my test app ?
Assignee | ||
Comment 10•9 years ago
|
||
Comment on attachment 8613813 [details] [diff] [review]
bug1101994-logshake.patch
Review of attachment 8613813 [details] [diff] [review]:
-----------------------------------------------------------------
::: b2g/components/LogShake.jsm
@@ +203,5 @@
> var acc = event.accelerationIncludingGravity;
>
> + var newExcitement = acc.x * acc.x + acc.y * acc.y + acc.z * acc.z;
> + // Low pass filter based on EXCITEMENT_FILTER_ALPHA
> + this.excitement += (newExcitement - this.excitement) * EXCITEMENT_FILTER_ALPHA;
Looks OK, but would be good to give proper documentation on how this will work for better understanding of further readers :)
Attachment #8613813 -
Flags: review?(lissyx+mozillians) → review+
Reporter | ||
Comment 11•9 years ago
|
||
Comment on attachment 8613813 [details] [diff] [review]
bug1101994-logshake.patch
I played around with this for a few minutes, and it seems to be much improved. I'd also like to see a button combination, since sometimes a shake is not always desirable. But that is orthogonal to this bug.
Attachment #8613813 -
Flags: review?(mhenretty) → review+
Comment 12•9 years ago
|
||
This is a graph comparing filtered and unfiltered excitement values. The y-axis is the excitement value, from x*x + y*y + z*z. The x-axis is time in milliseconds. 0-5000 is the phone at rest, 5000-10000 is a shake, 10000 onwards is gently shaking the device and dropping it from a height of one foot. The low pass filter successfully removes all of the peaks in the non-shaking region.
Should I add a comment to the code explaining how the low-pass filter works?
Assignee | ||
Comment 13•9 years ago
|
||
Michael, Dale landed such kind of key combo. It's VolUp+VolDown, as documented in bug 1155411.
Assignee | ||
Comment 14•9 years ago
|
||
(In reply to James Hobin from comment #12)
> Created attachment 8614259 [details]
> comparison.png
>
> This is a graph comparing filtered and unfiltered excitement values. The
> y-axis is the excitement value, from x*x + y*y + z*z. The x-axis is time in
> milliseconds. 0-5000 is the phone at rest, 5000-10000 is a shake, 10000
> onwards is gently shaking the device and dropping it from a height of one
> foot. The low pass filter successfully removes all of the peaks in the
> non-shaking region.
Nice, but this plot would be much better with legends and a title :)
>
> Should I add a comment to the code explaining how the low-pass filter works?
I think it's still valuable.
Comment 15•9 years ago
|
||
Attachment #8614259 -
Attachment is obsolete: true
Comment 16•9 years ago
|
||
I updated the comment to talk more about the rationale behind the filter and to mention this bug.
Attachment #8613813 -
Attachment is obsolete: true
Attachment #8614283 -
Flags: review?(lissyx+mozillians)
Assignee | ||
Comment 17•9 years ago
|
||
Comment on attachment 8614283 [details] [diff] [review]
bug1101994-logshake.patch
Review of attachment 8614283 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good, we now just lack some tests :)
Attachment #8614283 -
Flags: review?(lissyx+mozillians)
Comment 18•9 years ago
|
||
I added a test for ignoring a spike of motion due to dropping and refactored all of the other logshake tests to use an actual shake-type motion. This improves upon the previous approach of using a devicemotion event with impossibly high magnitude to trigger log capture.
I also found a small bug in the LogCapture tests where it is too tightly coupled to a kernel property and filed bug 1171577 to track that fix.
Attachment #8614283 -
Attachment is obsolete: true
Attachment #8615454 -
Flags: review?(lissyx+mozillians)
Assignee | ||
Comment 19•9 years ago
|
||
Comment on attachment 8615454 [details] [diff] [review]
Patch including unit tests and some test refactoring
Review of attachment 8615454 [details] [diff] [review]:
-----------------------------------------------------------------
Good work, and maybe we can even improve those tests!
::: b2g/components/test/unit/test_logshake.js
@@ +192,5 @@
> + LogShake.init();
> +
> + let readLocations = mockReadLogFile();
> +
> + // Device motion events occur once ever 160 ms on average
This test looks very good, I'd just like to know some rationale about it:
- where does those value come from
- can we avoid magic constants everywhere?
- can we make sure we cover many common usecases?
For instance, one case I can think of is:
- user has his device in his pocket; biking on a non good road with lots of movements
- user is running/doing is footing
- user is running in the subway in paris and takes stairs very quickly because he's aleady late in the office :)
Attachment #8615454 -
Flags: review?(lissyx+mozillians) → review+
Comment 20•9 years ago
|
||
I tried to remove or explain all of the magic numbers. It's slightly difficult because most of them are determined by guesswork or by looking at the graphs. I had my weekly exercise testing on the stairs and will be posting data from that soon.
Attachment #8615454 -
Attachment is obsolete: true
Attachment #8620715 -
Flags: review?(lissyx+mozillians)
Comment 21•9 years ago
|
||
Comment 22•9 years ago
|
||
I intended this to be as dramatic a motion as possible and it still doesn't trigger LogShake
Low pass filters are magical
Assignee | ||
Comment 23•9 years ago
|
||
Comment on attachment 8620715 [details] [diff] [review]
bug1101994-logshake.patch
Review of attachment 8620715 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me :)
::: b2g/components/LogShake.jsm
@@ +210,5 @@
>
> var acc = event.accelerationIncludingGravity;
>
> + // Updates excitement by a factor of at most alpha, ignoring sudden device
> + // motion. See bug #1101994 for more information.
Nit: how much sudden ?
Attachment #8620715 -
Flags: review?(lissyx+mozillians) → review+
Updated•9 years ago
|
Target Milestone: --- → 2.2 S14 (12june)
Comment 24•9 years ago
|
||
(In reply to Alexandre LISSY :gerard-majax from comment #23)
> Comment on attachment 8620715 [details] [diff] [review]
> bug1101994-logshake.patch
>
> Review of attachment 8620715 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Looks good to me :)
>
> ::: b2g/components/LogShake.jsm
> @@ +210,5 @@
> >
> > var acc = event.accelerationIncludingGravity;
> >
> > + // Updates excitement by a factor of at most alpha, ignoring sudden device
> > + // motion. See bug #1101994 for more information.
>
> Nit: how much sudden ?
It is slightly hard to provide accurate values. The maximum ignored spike is 5 times the force of gravity, which Wikipedia approximates as the force applied by a dragster or the maximum expected acceleration during a luge run at the Whistler Sliding Centre.
Keywords: checkin-needed
Comment 25•9 years ago
|
||
Try build here: https://treeherder.mozilla.org/#/jobs?repo=try&revision=8df4474ff727
Clearing checkin-needed until the build is done (forgot Autolander wasn't a thing)
Keywords: checkin-needed
Comment 26•9 years ago
|
||
Had to rerun to unblock intermittent failure, looks good now
Keywords: checkin-needed
Comment 27•9 years ago
|
||
Keywords: checkin-needed
Comment 29•9 years ago
|
||
Sure looks like it.
https://hg.mozilla.org/mozilla-central/rev/139a0155fd44
Status: NEW → RESOLVED
Closed: 9 years ago
status-b2g-master:
--- → fixed
status-firefox41:
--- → fixed
Flags: needinfo?(sheriffs)
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•