Closed
Bug 512237
Opened 15 years ago
Closed 15 years ago
Device Orientation issues
Categories
(Core :: Widget: Cocoa, defect)
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
status1.9.2 | --- | beta1-fixed |
People
(Reporter: dougt, Assigned: dougt)
References
Details
Attachments
(1 file, 5 obsolete files)
5.84 KB,
patch
|
smaug
:
review+
benjamin
:
approval1.9.2+
|
Details | Diff | Splinter Review |
+++ This bug was initially created as a clone of Bug #511902 +++
Created an attachment (id=395856)
patch v.1 (cocoa widget implementation)
Implementation for cocoa.
Smaug made these suggestions (which probably can apply to all implementations)
* AccelerationChanged shouldn't be called if acceleration hasn't changed.
* Currently it seems that mUpdateTimer just runs every 200ms. That should be 50ms or something to get smoother animations.
Assignee | ||
Updated•15 years ago
|
Summary: Device Orientation Support - cocoa → Device Orientation issues - cocoa
Comment 1•15 years ago
|
||
(In reply to comment #0)
> * AccelerationChanged shouldn't be called if acceleration hasn't changed.
But when an event listener is added, there should be MozOrientation event soon.
> * Currently it seems that mUpdateTimer just runs every 200ms. That should be
> 50ms or something to get smoother animations.
As the XXX comment in the code says, there could be a pref for this.
Assignee | ||
Comment 2•15 years ago
|
||
Assignee | ||
Comment 3•15 years ago
|
||
We may want to push the filtering into the platform specific code, but for now it should be fine here.
Attachment #396674 -
Attachment is obsolete: true
Attachment #396682 -
Flags: review?(Olli.Pettay)
Comment 4•15 years ago
|
||
The patch looks ok, but there is still one case to handle, I think.
When adding a MozOrientation listener first time to a window,
perhaps that window should get an event pretty soon so that it can get the initial values for the orientation. Does that make sense?
Assignee | ||
Comment 5•15 years ago
|
||
i do not think it matters that much because we get events pretty fast from the hardware. If we increased the delta to something like 0.1 or .2, then we would have to consider the case you are talking about.
Updated•15 years ago
|
Attachment #396682 -
Flags: review?(Olli.Pettay) → review+
Comment 6•15 years ago
|
||
Comment on attachment 396682 [details] [diff] [review]
patch v.2
> void
> nsAccelerometer::AccelerationChanged(double x, double y, double z)
> {
>+
>+ if ( PR_ABS(mLastX - x) < .01 &&
>+ PR_ABS(mLastY - y) < .01 &&
>+ PR_ABS(mLastZ - z) < .01 )
>+ return;
Extra space after ( and before )
>+
>+ mLastX = x; mLastY = y; mLastZ = z;
>+
Put these to separate lines.
>-protected:
>+ double mLastX, mLastY, mLastZ;
And these too.
Comment 7•15 years ago
|
||
(In reply to comment #5)
> i do not think it matters that much because we get events pretty fast from the
> hardware.
Well, some hardware may not provide results so fast. So if the the previous
value has been cached, and user doesn't move the device at all, it may
take long time before there is an orientation change which is above the change
threshold.
Comment 8•15 years ago
|
||
So, please fix that too.
Assignee | ||
Comment 9•15 years ago
|
||
ensures that all new listeners get the latest data when they are added.
Attachment #396682 -
Attachment is obsolete: true
Attachment #396687 -
Flags: review?(Olli.Pettay)
Comment 10•15 years ago
|
||
Comment on attachment 396687 [details] [diff] [review]
patch v.3
>@@ -144,16 +152,17 @@ NS_IMETHODIMP nsAccelerometer::AddListen
> {
> if (mStarted == PR_FALSE) {
> startDisconnectTimer();
> Startup();
> mStarted = PR_TRUE;
> }
>
> mListeners.AppendObject(aListener);
>+ AccelerationChanged(mLastX, mLastY, mLastZ, PR_FALSE);
> return NS_OK;
> }
>
> NS_IMETHODIMP nsAccelerometer::RemoveListener(nsIAccelerationListener *aListener)
> {
> mListeners.RemoveObject(aListener);
> return NS_OK;
> }
>@@ -162,28 +171,41 @@ NS_IMETHODIMP nsAccelerometer::AddWindow
> {
> if (mStarted == PR_FALSE) {
> startDisconnectTimer();
> Startup();
> mStarted = PR_TRUE;
> }
>
> mWindowListeners.AppendObject(aWindow);
>+ AccelerationChanged(mLastX, mLastY, mLastZ, PR_FALSE);
> return NS_OK;
> }
>
Sorry to be such a nitpicker, but is that really a safe time to dispatch an event?
Perhaps you could have something like "ResetCachedValues()", which would force the
next (asynchronous) AccelerationChanged?
Assignee | ||
Comment 11•15 years ago
|
||
no problem about nitpicking; that is what this process is for.
Are you worried that the listener will be called before AddEventListener returns?
Comment 12•15 years ago
|
||
(In reply to comment #11)
> Are you worried that the listener will be called before AddEventListener
> returns?
Well, for example about that.
Calling the listener asynchronously would be good.
Adding some reset flag should be trivial.
Comment 13•15 years ago
|
||
I mean some flag which cause the next timer run to call AccelerationChanged.
Updated•15 years ago
|
Attachment #396687 -
Flags: review?(Olli.Pettay)
Assignee | ||
Comment 14•15 years ago
|
||
This adds a new timer that fires 10ms after the event listener is added (hopeful enough time for us to recv data) ensuring that data is passed to new listeners.
Attachment #396687 -
Attachment is obsolete: true
Attachment #396878 -
Flags: review?(Olli.Pettay)
Assignee | ||
Comment 15•15 years ago
|
||
Attachment #396878 -
Attachment is obsolete: true
Attachment #396885 -
Flags: review?(Olli.Pettay)
Attachment #396878 -
Flags: review?(Olli.Pettay)
Comment 16•15 years ago
|
||
[02:18] <smaug> dougt: this is not really about this bug... but the reason for StartDisconnectTimer is to not shutdown immediately?
[02:19] <smaug> dougt: could we start that in RemoveListener if there are no listeners
[02:20] <smaug> dougt: in RemoveListener/RemoveWindowListener if mListeners.Count() == 0 && mWindowListeners.Count()
[02:20] <smaug> dougt: and if someone adds a new listener, cancel that timer
[02:22] <smaug> dougt: I'm assuming here that the reason to not shutdown immediately is to prevent activate/deactivate accelerometer all the time
Assignee | ||
Updated•15 years ago
|
Summary: Device Orientation issues - cocoa → Device Orientation issues
Assignee | ||
Comment 17•15 years ago
|
||
Attachment #396885 -
Attachment is obsolete: true
Attachment #396902 -
Flags: review?(Olli.Pettay)
Attachment #396885 -
Flags: review?(Olli.Pettay)
Comment 18•15 years ago
|
||
Comment on attachment 396902 [details] [diff] [review]
patch v.6
> void
> nsAccelerometer::AccelerationChanged(double x, double y, double z)
> {
>+ if (x > 1 || y > 1 || z > 1 || x < -1 || y < -1 || z < -1)
>+ return;
>+
>+ if (!mNewListener) {
>+ if (PR_ABS(mLastX - x) < .01 &&
>+ PR_ABS(mLastY - y) < .01 &&
>+ PR_ABS(mLastZ - z) < .01)
>+ return;
>+ }
>+
>+ mLastX = x;
>+ mLastY = y;
>+ mLastZ = z;
>+
You need to set mNewListener to PR_FALSE here.
Attachment #396902 -
Flags: review?(Olli.Pettay) → review+
Assignee | ||
Comment 19•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•15 years ago
|
Attachment #396902 -
Flags: approval1.9.2?
Updated•15 years ago
|
Attachment #396902 -
Flags: approval1.9.2? → approval1.9.2+
Assignee | ||
Comment 20•15 years ago
|
||
status1.9.2:
--- → beta1-fixed
Component: Widget: Mac → Widget: Cocoa
Product: Core Graveyard → Core
QA Contact: mac → cocoa
You need to log in
before you can comment on or make changes to this bug.
Description
•