Bug 132857 - [iOS] Page scale update messages for media controls should only fire at the end of zooming
Summary: [iOS] Page scale update messages for media controls should only fire at the e...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-13 01:36 PDT by Dean Jackson
Modified: 2014-05-13 17:10 PDT (History)
6 users (show)

See Also:


Attachments
Patch (11.83 KB, patch)
2014-05-13 04:57 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (16.34 KB, patch)
2014-05-13 14:30 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (8.34 KB, patch)
2014-05-13 15:58 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (8.80 KB, patch)
2014-05-13 16:22 PDT, Dean Jackson
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2014-05-13 01:36:50 PDT
[iOS] Page scale update messages for media controls should only fire at the end of zooming
Comment 1 Dean Jackson 2014-05-13 04:57:21 PDT
Created attachment 231370 [details]
Patch
Comment 2 Benjamin Poulain 2014-05-13 11:56:59 PDT
Comment on attachment 231370 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=231370&action=review

I'll have a look.

My first take is: I don't understand why would this be related to the pinch gesture. Why wouldn't you update the media control on programmatic zoom (e.g. double tap) and scale changes originating from the WebProcess (e.g. Content Width changes, and is rescaled to fit into view).

> Source/WebCore/page/Page.cpp:788
> +            frame->document()->pageScaleFactorChanged();

The method pageScaleFactorChanged() should probably be renamed to something specific to media, and to a name that make it clear that it can be out of sync with the page scale factor.

As it is with the patch, it counter intuitive that you would call pageScaleFactorChanged() only when a user triggered zoom ends.

It is also unclear why would one call pageScaleFactorChanged() on every document when only the scale factor of the main frame changed.
Comment 3 Dean Jackson 2014-05-13 12:11:10 PDT
(In reply to comment #2)
> (From update of attachment 231370 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=231370&action=review
> 
> I'll have a look.
> 
> My first take is: I don't understand why would this be related to the pinch gesture. Why wouldn't you update the media control on programmatic zoom (e.g. double tap) and scale changes originating from the WebProcess (e.g. Content Width changes, and is rescaled to fit into view).

Yeah, that's a mistake. This should happen any time zoom changes. The idea is just to stop it happening during a pinch... so I should move the functionality back into the setPageScaleFactor method.

> 
> > Source/WebCore/page/Page.cpp:788
> > +            frame->document()->pageScaleFactorChanged();
> 
> The method pageScaleFactorChanged() should probably be renamed to something specific to media, and to a name that make it clear that it can be out of sync with the page scale factor.

I think I should do half of that. I think I should remove the guards around the code that mention MEDIA, because this could really apply to anything.

Then, yeah, I need to think of a better name.... pageScaleFactorCommitted?

> 
> As it is with the patch, it counter intuitive that you would call pageScaleFactorChanged() only when a user triggered zoom ends.
> 
> It is also unclear why would one call pageScaleFactorChanged() on every document when only the scale factor of the main frame changed.
Comment 4 Dean Jackson 2014-05-13 14:30:23 PDT
Created attachment 231407 [details]
Patch
Comment 5 Dean Jackson 2014-05-13 14:34:07 PDT
From Ben's comments:

- renamed the method to make it clear it's only about media controls
- call the "commit change for media" method during page scale changes unless we're in the middle of a zoom (covering double tap and other things)
- only calling the method on the main frame
Comment 6 Simon Fraser (smfr) 2014-05-13 14:39:20 PDT
Comment on attachment 231407 [details]
Patch

VisibleContentRectUpdateInfo already has inStableState(); you should use this instead of plumbing through more ways to know if a zoom is in progress.
Comment 7 Benjamin Poulain 2014-05-13 15:30:22 PDT
(In reply to comment #6)
> (From update of attachment 231407 [details])
> VisibleContentRectUpdateInfo already has inStableState(); you should use this instead of plumbing through more ways to know if a zoom is in progress.

The problem with that is if you start pinching, then lift a single finger and continue scrolling.

That is not a stable update, yet we should update anything that depends on a stable scale factor.

At the moment, WKWebView does not differentiate. It seems Dean will need to break stable state in two: "stableState" and "scaleFactorIsStable".
Comment 8 Dean Jackson 2014-05-13 15:58:55 PDT
Created attachment 231413 [details]
Patch
Comment 9 Simon Fraser (smfr) 2014-05-13 16:12:53 PDT
Comment on attachment 231413 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=231413&action=review

> Source/WebCore/dom/Document.h:1045
> -    void pageScaleFactorChanged();
> +    void pageScaleFactorCommittedForMedia();

I would prefer this not have "ForMedia" in the name. We may need to hook other things up to stable scale changes. Maybe pageScaleFactorChangeToStableValue or something. gotStableScaleChange?

> Source/WebCore/page/Page.cpp:765
> -    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
> -        frame->document()->pageScaleFactorChanged();
> +    if (inStableState)
> +        mainFrame().document()->pageScaleFactorCommittedForMedia();

You've lost going through subframes in this patch.

> Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2162
> +    m_page->setPageScaleFactor(floatBoundedScale, scrollPosition, visibleContentRectUpdateInfo.inStableState());

This changes means that we'll be changing the scale factor without checking floatBoundedScale != m_page->pageScaleFactor(), which I suspect will cause some bad things to happen (maybe when pinching?)

I think you should only call m_page->setPageScaleFactor() here if the state is stable.
Comment 10 Dean Jackson 2014-05-13 16:22:25 PDT
Created attachment 231416 [details]
Patch
Comment 11 Simon Fraser (smfr) 2014-05-13 16:25:02 PDT
Comment on attachment 231416 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=231416&action=review

> Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2162
> +    bool toldPageThatScaleHasChanged = false;

Could be just hasSetPageScale I think
Comment 12 Dean Jackson 2014-05-13 17:10:29 PDT
Committed r168761: <http://trac.webkit.org/changeset/168761>