coalesce the device motion events

RESOLVED FIXED in mozilla14

Status

()

defect
RESOLVED FIXED
8 years ago
5 years ago

People

(Reporter: dougt, Assigned: dougt)

Tracking

unspecified
mozilla14
x86
macOS
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

We can improve perf a bit by not sending 3 separate dom events.  Instead, we can coalesce the device motion events by waiting a bit to see if there is additional motion data before posting the dom event.
Posted patch patch v.1Splinter Review
Attachment #604421 - Flags: review?(josh)
Comment on attachment 604421 [details] [diff] [review]
patch v.1

Review of attachment 604421 [details] [diff] [review]:
-----------------------------------------------------------------

r=me

::: dom/system/nsDeviceMotion.cpp
@@ +344,5 @@
>                                     double x,
>                                     double y,
>                                     double z) {
> +  // Attempt to coalesce events
> +  bool fireEvent = false;

Just assign the result of the condition to fireEvent?

@@ +345,5 @@
>                                     double y,
>                                     double z) {
> +  // Attempt to coalesce events
> +  bool fireEvent = false;
> +  if (PR_IntervalNow() > mLastDOMMotionEventTime + PR_MillisecondsToInterval(DEFAULT_SENSOR_POLL))

Let's use TimeStamp::Now() and TimeDuration::FromMilliseconds instead.

@@ +391,5 @@
> +
> +  mLastRotationRate = nsnull;
> +  mLastAccelerationIncluduingGravity = nsnull;
> +  mLastAcceleration = nsnull;
> +  mLastDOMMotionEventTime = PR_IntervalNow();

TimeStamp::Now()

::: dom/system/nsDeviceMotion.h
@@ +98,5 @@
>    virtual void Startup()  = 0;
>    virtual void Shutdown() = 0;
> +
> +  bool mEnabled;
> +  PRIntervalTime mLastDOMMotionEventTime;

TimeStamp
Attachment #604421 - Flags: review?(josh) → review+
Re-landed and merged:
https://hg.mozilla.org/mozilla-central/rev/ed1d52905a61
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla14
Depends on: 1095867
You need to log in before you can comment on or make changes to this bug.