Closed
Bug 949132
Opened 11 years ago
Closed 11 years ago
Replace UpdateScrollOffset with a flag on the FrameMetrics during layer updates
Categories
(Core :: Panning and Zooming, defect)
Tracking
()
People
(Reporter: kats, Assigned: kats)
References
Details
Attachments
(2 files, 2 obsolete files)
(deleted),
patch
|
tnikkel
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
cwiiis
:
review+
|
Details | Diff | Splinter Review |
As one of the possible solutions to bug 947337 we discussed getting rid of the UpdateScrollOffset method on APZCTreeManager/AsyncPanZoomController. Instead, we could have a flag on the FrameMetrics that is set when content does a scrollTo, and then during the layers update the APZC could pick up the scroll offset from the frame metrics. Markus provided a patch on that bug to accomplish this.
Although that patch didn't fix that bug I'd still like to land it because it results in cleaner code so I'm forking it over to this bug.
Comment 1•11 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #0)
> As one of the possible solutions to bug 947337 we discussed getting rid of
> the UpdateScrollOffset method on APZCTreeManager/AsyncPanZoomController.
> Instead, we could have a flag on the FrameMetrics that is set when content
> does a scrollTo, and then during the layers update the APZC could pick up
> the scroll offset from the frame metrics. Markus provided a patch on that
> bug to accomplish this.
This will be in addition to, not instead of, getting rid of UpdateScrollOffset, right?
Assignee | ||
Comment 2•11 years ago
|
||
Yeah. We can get rid of UpdateScrollOffset if we have the flag.
Assignee | ||
Comment 3•11 years ago
|
||
This is Markus' patch from bug 947337, with two changes:
1) Updated UUID for nsIDOMWindowUtils.idl
2) Renamed mWasScrolledByContent to be mWasScrolledByApz (and inverted the meaning). I did this because there other things that can trigger scrolls, like mouse wheel movements, and so the thing we really want to distinguish is APZ-driven scrolling vs everything else.
Attachment #8346171 -
Flags: review?(tnikkel)
Assignee | ||
Comment 4•11 years ago
|
||
I've tested this on B2G but haven't built Fennec/Metro with it yet. Will push to try.
Attachment #8346172 -
Flags: review?(jmathies)
Attachment #8346172 -
Flags: review?(botond)
Assignee | ||
Comment 5•11 years ago
|
||
Comment 6•11 years ago
|
||
Comment on attachment 8346171 [details] [diff] [review]
Part 1 - Add a flag on FrameMetrics
>@@ -2045,16 +2047,18 @@ ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange)
> ScheduleSyntheticMouseMove();
> nsWeakFrame weakFrame(mOuter);
> UpdateScrollbarPosition();
> if (!weakFrame.IsAlive()) {
> return;
> }
> PostScrollEvent();
>
>+ mOriginOfLastScroll = aOrigin;
>+
> // notify the listeners.
> for (uint32_t i = 0; i < mListeners.Length(); i++) {
> mListeners[i]->ScrollPositionDidChange(pt.x, pt.y);
> }
> }
Minor point: I would update mOriginOfLastScroll a little earlier, since the scroll has happened, and the weakframe check shows that we will enter other code here, if it ever checks the origin of last scroll it will be out of date. I would say after we set the position of the scrolled frame.
General question: what happens if we get an apz scroll, then a scroll from somewhere else, and then we trigger a layers update? Would that cause a problem?
Attachment #8346171 -
Flags: review?(tnikkel) → review+
Assignee | ||
Comment 7•11 years ago
|
||
(In reply to Timothy Nikkel (:tn) from comment #6)
> General question: what happens if we get an apz scroll, then a scroll from
> somewhere else, and then we trigger a layers update? Would that cause a
> problem?
That scenario is actually ok because then mWasScrolledByApz will be false, and so in the APZC code we'll take the new scroll offset as desired. The problem is actually the opposite scenario, where we get a content scrollTo, then an inflight apz scroll is processed, and then we trigger a layers update, because then mWasScrolledByApz will be true and will mask the fact that there was a content scrollTo. (Also we'll end up losing the scroll position of the content scrollTo because the apz scroll will clobber it).
Previously this was handled because the UpdateScrollOffset would set the content scrollTo value in the APZC so even if it got clobbered by an inflight apz scroll, the next apz scroll would have the right value. The only way I see to not regress this behaviour with the new patches is to add some logic in ScrollToImpl that throws away apz scrolls between a non-apz scroll and the corresponding layers update. This would involve adding a "non-apz" atom and using that for all scrolls other than apz-driven scrolls, and being able to reset the mOriginOfLastScroll as part of RecordFrameMetrics. Doable but kinda ugly because it's putting logic into nsGfxScrollFrame that maybe doesn't belong there.
Comment 8•11 years ago
|
||
Comment on attachment 8346172 [details] [diff] [review]
Part 2 - Use the flag and delete a mountain of code
no identifiable side effects as far as I can tell.
Attachment #8346172 -
Flags: review?(jmathies) → review+
Comment 9•11 years ago
|
||
cc'ing matt so he knows this code is coming out.
Comment 10•11 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #7)
> Previously this was handled because the UpdateScrollOffset would set the
> content scrollTo value in the APZC so even if it got clobbered by an
> inflight apz scroll, the next apz scroll would have the right value. The
> only way I see to not regress this behaviour with the new patches is to add
> some logic in ScrollToImpl that throws away apz scrolls between a non-apz
> scroll and the corresponding layers update. This would involve adding a
> "non-apz" atom and using that for all scrolls other than apz-driven scrolls,
> and being able to reset the mOriginOfLastScroll as part of
> RecordFrameMetrics. Doable but kinda ugly because it's putting logic into
> nsGfxScrollFrame that maybe doesn't belong there.
Would the apzc callback that updates the scroll position not have enough information to determine if it should update the scroll position? Could we provide accessors so it does?
Assignee | ||
Comment 11•11 years ago
|
||
You were right, I can move that logic into APZCCallbackHelper and it ends up being cleaner. Here is an updated patch. I renamed the flag on FrameMetrics again because it turned out I need to invert the boolean again to catch some other cases.
Attachment #8346171 -
Attachment is obsolete: true
Attachment #8346892 -
Flags: review?(tnikkel)
Assignee | ||
Comment 12•11 years ago
|
||
This is pretty much the same as before but rebased. Carrying jim's r+ and r? for botond.
Attachment #8346172 -
Attachment is obsolete: true
Attachment #8346172 -
Flags: review?(botond)
Attachment #8346894 -
Flags: review?(botond)
Comment 13•11 years ago
|
||
Comment on attachment 8346892 [details] [diff] [review]
Part 1 - Add a flag on FrameMetrics (v2)
>+ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, nsIAtom* aOrigin)
> {
>+ if (aOrigin == nullptr) {
>+ // If no origin was specified, we still want to set it to something that's
>+ // non-null, so that we can use nullness to distinguish if the frame was scrolled
>+ // at all. Default it to some generic placeholder.
>+ aOrigin = nsGkAtoms::generic_;
>+ }
There are a few places already in the scroll frame code where we have the same pattern but we use the "other" atom. Can that work for this too?
Attachment #8346892 -
Flags: review?(tnikkel) → review+
Assignee | ||
Comment 14•11 years ago
|
||
Yeah I can change that. I just glanced through the list of atoms and picked the first one that sounded appropriate.
Assignee | ||
Comment 15•11 years ago
|
||
Btw the try run for these patches is also clean
https://tbpl.mozilla.org/?tree=Try&rev=24891d16cc00
Assignee | ||
Comment 17•11 years ago
|
||
That depends. For me the patches on this bug solve bug 947337 on both the Peak and hamachi devices. Vivien said he could still reproduce bug 947337 with (an earlier version of) these patches. I would like him to re-test with the latest version of these patches; if they work for him AND we want to fix bug 947337 in 1.3, then this would need to go on that train.
Comment 18•11 years ago
|
||
Comment on attachment 8346894 [details] [diff] [review]
Part 2 - Use the flag and delete a mountain of code
Will steal this, but leaving r?botond for now in case he gets to it before I do (because I can't do it right now)
Attachment #8346894 -
Flags: review?(chrislord.net)
Comment 19•11 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #17)
> That depends. For me the patches on this bug solve bug 947337 on both the
> Peak and hamachi devices. Vivien said he could still reproduce bug 947337
> with (an earlier version of) these patches. I would like him to re-test with
> the latest version of these patches; if they work for him AND we want to fix
> bug 947337 in 1.3, then this would need to go on that train.
OK, so the Comment 0 "one of the possible solutions to bug 947337 is to fix this" is really "we must fix this to fix bug 947337"?
Assignee | ||
Comment 20•11 years ago
|
||
(In reply to Milan Sreckovic [:milan] from comment #19)
> OK, so the Comment 0 "one of the possible solutions to bug 947337 is to fix
> this" is really "we must fix this to fix bug 947337"?
Given my current understanding of what's happening in bug 947337, yes. It could be that my understanding is wrong, though. I'm putting together some additional logging patches that might help shed some more light on the matter.
Comment 21•11 years ago
|
||
Thanks. If you verify the dependency, rather than option, can you make it 1.3?
Comment 22•11 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #17)
> That depends. For me the patches on this bug solve bug 947337 on both the
> Peak and hamachi devices. Vivien said he could still reproduce bug 947337
> with (an earlier version of) these patches. I would like him to re-test with
> the latest version of these patches; if they work for him AND we want to fix
> bug 947337 in 1.3, then this would need to go on that train.
My feeling is that we want to fix bug 947337 in 1.3. I don't mind to land a stop gap as the patch I proposed in bug 947337 even if I agree this is not the right fix and it may have side issues (which seems hard to trigger imho). Then you will have plenty of time to fix the real issue in 1.4 :)
In the meantime I will retry with this patch as soon as I can.
Comment 23•11 years ago
|
||
(In reply to Vivien Nicolas (:vingtetun) (:21) from comment #22)
> (In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #17)
> > That depends. For me the patches on this bug solve bug 947337 on both the
> > Peak and hamachi devices. Vivien said he could still reproduce bug 947337
> > with (an earlier version of) these patches. I would like him to re-test with
> > the latest version of these patches; if they work for him AND we want to fix
> > bug 947337 in 1.3, then this would need to go on that train.
>
> My feeling is that we want to fix bug 947337 in 1.3. I don't mind to land a
> stop gap as the patch I proposed in bug 947337 even if I agree this is not
> the right fix and it may have side issues (which seems hard to trigger
> imho). Then you will have plenty of time to fix the real issue in 1.4 :)
>
> In the meantime I will retry with this patch as soon as I can.
With this patch I can reproduce bug 947337 and bug 942752.
Here is an example of the wrong values:
I/GeckoDump(11066): Event: pageY: 372
I/GeckoDump(11066): Event: pageY: 211
I/GeckoDump(11066): Event: pageY: 211
I/GeckoDump(11066): Event: pageY: -34092
I/GeckoDump(11066): Event: pageY: -34092
I/GeckoDump(11066): Event: pageY: -34092
I/GeckoDump(11066): Event: pageY: 349
I/GeckoDump(11066): Event: pageY: 349
I/GeckoDump(11066): Event: pageY: 276
I/GeckoDump(11066): Event: pageY: 276
I/GeckoDump(11066): Event: pageY: 31955
I/GeckoDump(11066): Event: pageY: 241
I/GeckoDump(11066): Event: pageY: -10365
I/GeckoDump(11066): Event: pageY: 201
Assignee | ||
Comment 24•11 years ago
|
||
Can you also provide the exact patch you are using to get the above output?
Comment 25•11 years ago
|
||
Comment on attachment 8346894 [details] [diff] [review]
Part 2 - Use the flag and delete a mountain of code
Review of attachment 8346894 [details] [diff] [review]:
-----------------------------------------------------------------
Stealing review. This is glorious, land it.
::: gfx/layers/ipc/AsyncPanZoomController.cpp
@@ +1490,5 @@
> mFrameMetrics.mResolution = aLayerMetrics.mResolution;
> mFrameMetrics.mCumulativeResolution = aLayerMetrics.mCumulativeResolution;
> +
> + // If the layers update was not triggered by a repaint of our own repaint
> + // request, then we want to take the new scroll offset.
This comment reads a bit oddly - how about just 'If the layers update was not triggered by our own repaint request'?
Attachment #8346894 -
Flags: review?(chrislord.net)
Attachment #8346894 -
Flags: review?(botond)
Attachment #8346894 -
Flags: review+
Assignee | ||
Comment 26•11 years ago
|
||
Fixed the comment and landed:
remote: https://hg.mozilla.org/integration/b2g-inbound/rev/d49be6bd6378
remote: https://hg.mozilla.org/integration/b2g-inbound/rev/5047906b359f
Comment 27•11 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #24)
> Can you also provide the exact patch you are using to get the above output?
I'm just adding a |dump(currentY);| at https://github.com/mozilla-b2g/gaia/blob/master/apps/communications/contacts/js/contacts_shortcuts.js#L128
Comment 28•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/d49be6bd6378
https://hg.mozilla.org/mozilla-central/rev/5047906b359f
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Comment 29•11 years ago
|
||
Do we want this in b2g1.3/Aurora? I would suggest that we do, given the code it replaces had possible race conditions.
Assignee | ||
Comment 30•11 years ago
|
||
Yeah, I agree. It will also make uplifting future patches easier.
blocking-b2g: --- → 1.3?
status-firefox27:
--- → wontfix
status-firefox28:
--- → affected
status-firefox29:
--- → fixed
Comment 31•11 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #30)
> Yeah, I agree. It will also make uplifting future patches easier.
I think this is a strong reason to ask for aurora approval, but not a reason to block the release. Can you nominate this for aurora approval?
blocking-b2g: 1.3? → -
Assignee | ||
Comment 32•11 years ago
|
||
Comment on attachment 8346892 [details] [diff] [review]
Part 1 - Add a flag on FrameMetrics (v2)
[Approval Request Comment]
Bug caused by (feature/regressing bug #): original APZ code
User impact if declined: Possible race conditions when scrolling while content is doing scrollTo calls can result in unexpected jumps or bad touch events. Also uplifting to aurora will make future APZ code uplifts easier
Testing completed (on m-c, etc.): on m-c for a while now
Risk to taking this patch (and alternatives if risky): pretty low risk, it's baked a while and it's well understood
String or IDL/UUID changes made by this patch: UUID change on nsIDOMWindowUtils.idl to remove a function that is no longer needed.
Attachment #8346892 -
Flags: approval-mozilla-aurora?
Assignee | ||
Comment 33•11 years ago
|
||
Comment on attachment 8346894 [details] [diff] [review]
Part 2 - Use the flag and delete a mountain of code
Same as above
Attachment #8346894 -
Flags: approval-mozilla-aurora?
Comment 36•11 years ago
|
||
This is duplicating bug 947337 which is 1.3+, so we need to 1.3+ this one and make sure uplift happens.
blocking-b2g: - → 1.3+
Updated•11 years ago
|
Attachment #8346892 -
Flags: approval-mozilla-aurora?
Updated•11 years ago
|
Attachment #8346894 -
Flags: approval-mozilla-aurora?
Comment 37•11 years ago
|
||
https://hg.mozilla.org/releases/mozilla-aurora/rev/3e186f49cbb6
https://hg.mozilla.org/releases/mozilla-aurora/rev/d315166e96b4
status-b2g-v1.3:
--- → fixed
Updated•11 years ago
|
status-b2g-v1.3T:
--- → fixed
status-b2g-v1.4:
--- → fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•