Closed Bug 734391 Opened 12 years ago Closed 12 years ago

coalesce the device motion events

Categories

(Core :: DOM: Geolocation, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: dougt, Assigned: dougt)

References

Details

Attachments

(1 file)

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.
Attached 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: 12 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.