Bug 113326

Summary: [Qt][WK2] Regression(141310): Page flickers during scale animation
Product: WebKit Reporter: Andras Becsi <abecsi>
Component: New BugsAssignee: Andras Becsi <abecsi>
Status: RESOLVED INVALID    
Severity: Normal CC: allan.jensen, benjamin, cmarcelo, eflews.bot, gyuyoung.kim, gyuyoung.kim, helder.correia, jturcotte, kenneth, luiz, menard, noam, rakuco, webkit.review.bot, zeno
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 110211    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Andras Becsi 2013-03-26 10:44:38 PDT
[Qt][WK2] Regression(141310): Page flickers during scale animation
Comment 1 Andras Becsi 2013-03-26 10:46:10 PDT
Created attachment 195117 [details]
Patch
Comment 2 Noam Rosenthal 2013-03-26 10:51:52 PDT
Comment on attachment 195117 [details]
Patch

I'm ok with the coordinated graphics changes. Can you ask Kenneth/Jocelyn to also look before asking for a WK2 owner sign off?
Comment 3 Andras Becsi 2013-03-26 10:53:31 PDT
(In reply to comment #2)
> (From update of attachment 195117 [details])
> I'm ok with the coordinated graphics changes. Can you ask Kenneth/Jocelyn to also look before asking for a WK2 owner sign off?

Thanks, Jocelyn could you take a look?
Comment 4 EFL EWS Bot 2013-03-26 11:27:06 PDT
Comment on attachment 195117 [details]
Patch

Attachment 195117 [details] did not pass efl-ews (efl):
Output: http://webkit-commit-queue.appspot.com/results/17236651
Comment 5 Andras Becsi 2013-03-26 11:29:34 PDT
(In reply to comment #4)
> (From update of attachment 195117 [details])
> Attachment 195117 [details] did not pass efl-ews (efl):
> Output: http://webkit-commit-queue.appspot.com/results/17236651

Hmm, EFL seems to depend on the wrong behaviour. I'll have to check what's going on there.
Comment 6 Andras Becsi 2013-03-27 05:12:13 PDT
Created attachment 195282 [details]
Patch
Comment 7 Andras Becsi 2013-03-27 06:22:39 PDT
(In reply to comment #6)
> Created an attachment (id=195282) [details]
> Patch

Fixed the EFL build.
Comment 8 Jocelyn Turcotte 2013-03-27 06:44:27 PDT
Comment on attachment 195282 [details]
Patch

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

LGTM but here is something that would be nice to verify twice:

> Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:140
> +    m_drawingAreaProxy->page()->scalePage(scale, roundedIntPoint(rect.location()));
>      m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::SetVisibleContentsRect(rect, trajectoryVector), m_drawingAreaProxy->page()->pageID());

This might still create the issue that the scale change might trigger a layer flush with a visibleRect's size that is not matching the scale.
For example, if you're zommed out and your page coord visible rect is 500x500 with a scale of 0.5 (a window size of 250x250), zooming in would trigger a tile update using a visibleRect of 125x125 with a scale of 2 (again 250x250).

If the scale change does trigger a layer flush before the matching visibleRect update message is handled, you'll end up rendering a 500x500 rect with a scale of 2: 1000x1000 for the viewport. 2000x2000 if you take into account the TiledBackingStore 2x cover rect multiplier.

Could you verify with some printf in TiledBackingStore::createTiles that the tilesToCreateCount isn't growing astronomically when zooming in? We might not hit that case by luck since a flush is scheduled back on the event loop, giving time to the visible rect update message to be handled, but I'm not sure.
Comment 9 Jocelyn Turcotte 2013-03-27 06:45:52 PDT
The PageViewportController::didChangeContentsVisibility call still in the PageViewportControllerClientEfl::setViewportPosition PVC callback could cause problems with this patch. So hopefully somebody will be testing zooming with EFL.
Comment 10 Andras Becsi 2013-03-27 07:17:45 PDT
(In reply to comment #9)
> The PageViewportController::didChangeContentsVisibility call still in the PageViewportControllerClientEfl::setViewportPosition PVC callback could cause problems with this patch. So hopefully somebody will be testing zooming with EFL.

Qt also has that call indirectlz through the contentX and contentY change notifications, but EFL needs to call it directly. I did not see any issues there but it would be good if someone could verify.
Comment 11 Andras Becsi 2013-03-27 09:02:55 PDT
(In reply to comment #8)
> (From update of attachment 195282 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=195282&action=review
> 
> LGTM but here is something that would be nice to verify twice:
> 
> > Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:140
> > +    m_drawingAreaProxy->page()->scalePage(scale, roundedIntPoint(rect.location()));
> >      m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::SetVisibleContentsRect(rect, trajectoryVector), m_drawingAreaProxy->page()->pageID());
> 
> This might still create the issue that the scale change might trigger a layer flush with a visibleRect's size that is not matching the scale.
> For example, if you're zommed out and your page coord visible rect is 500x500 with a scale of 0.5 (a window size of 250x250), zooming in would trigger a tile update using a visibleRect of 125x125 with a scale of 2 (again 250x250).
> 
> If the scale change does trigger a layer flush before the matching visibleRect update message is handled, you'll end up rendering a 500x500 rect with a scale of 2: 1000x1000 for the viewport. 2000x2000 if you take into account the TiledBackingStore 2x cover rect multiplier.
> 
> Could you verify with some printf in TiledBackingStore::createTiles that the tilesToCreateCount isn't growing astronomically when zooming in? We might not hit that case by luck since a flush is scheduled back on the event loop, giving time to the visible rect update message to be handled, but I'm not sure.

I couldn't produce such a scenario. The tile creation always started after the visibleRect update was processed but never in between the scale setting and the visible rect update.

I do not have a concept of astronomical in this context but the biggest number of tilesToCreateCount in TiledBackingStore::createTiles was 10 during double-tap zoom-in.
Comment 12 Jocelyn Turcotte 2013-04-02 11:04:02 PDT
Comment on attachment 195282 [details]
Patch

LGTM for Qt, I'm still not sure for EFL so I think it would be best to get their blessing too.
Comment 13 Jocelyn Turcotte 2013-04-02 11:05:02 PDT
(In reply to comment #11)
> I couldn't produce such a scenario. The tile creation always started after the visibleRect update was processed but never in between the scale setting and the visible rect update.
> 
> I do not have a concept of astronomical in this context but the biggest number of tilesToCreateCount in TiledBackingStore::createTiles was 10 during double-tap zoom-in.

Ok in any case the patch is an improvement in that regard, thanks for checking.
Comment 14 Andras Becsi 2013-04-03 02:35:36 PDT
(In reply to comment #12)
> (From update of attachment 195282 [details])
> LGTM for Qt, I'm still not sure for EFL so I think it would be best to get their blessing too.

Kenneth, could you check this for EFL with one of your magic manual tests?
I ran a quick test with an EFL build and did not see suspicious behaviour.
Comment 15 Andras Becsi 2013-04-05 05:03:03 PDT
Ping for review?
Comment 16 Andras Becsi 2013-04-05 09:41:55 PDT
Created attachment 196645 [details]
Patch
Comment 17 Andras Becsi 2013-04-05 09:43:55 PDT
(In reply to comment #16)
> Created an attachment (id=196645) [details]
> Patch

Updated to apply on ToT.
Comment 18 Mikhail Pozdnyakov 2013-04-08 02:04:52 PDT
Comment on attachment 196645 [details]
Patch

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

> Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:45
> +    , m_lastSentScale(0)

ah another scale :( but isn't it the same as pagescalefactor from page proxy?
Comment 19 Andras Becsi 2013-04-08 06:05:00 PDT
Comment on attachment 196645 [details]
Patch

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

>> Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:45
>> +    , m_lastSentScale(0)
> 
> ah another scale :( but isn't it the same as pagescalefactor from page proxy?

It is technically the same scale factor, but the represented state is different.

In theory I could put a scale and scroll position equality check to WebPageProxy::scalePage, but WebPageProxy::m_pageScaleFactor has to be initialized to 1, since it is exposed, so an initial scale setting of 1 would not reach the web process causing behavior change and potential problems.

I also think that the name makes the state this variable represents clear, but I could rename it to something like m_lastCommittedPageScaleFactor, if you think it confusing.
Comment 20 Andras Becsi 2013-04-11 04:27:14 PDT
Created attachment 197573 [details]
Patch
Comment 21 Jocelyn Turcotte 2013-04-17 05:19:43 PDT
Comment on attachment 197573 [details]
Patch

r=me, just make sure you get an WK2 owner to look at it. (CC'd Benjamin)
Comment 22 Benjamin Poulain 2013-04-17 13:44:36 PDT
Comment on attachment 197573 [details]
Patch

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

I have two little issues with this patch:

I think the method is badly named.
Something named "setVisibleContentsRect" should take a rect, not a rect, a scale and a "trajectoryVector" (I assume normalized). You should either split it in three method calls, or look for a more descriptive name.

The scale of 1 passed for the page scale factor is really weird. I don't really understand why that would be correct. For example, a page has a scale of 0.3, the user resize the view, shouldn't the scale be re-computed for the viewport parameters?

> Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:102
> +    float m_lastSentPageScaleFactor;

float->double (the page scale factor is typed double).
Comment 23 Andras Becsi 2013-04-17 15:33:30 PDT
(In reply to comment #22)
> (From update of attachment 197573 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=197573&action=review
> 
> I have two little issues with this patch:
> 
> I think the method is badly named.
> Something named "setVisibleContentsRect" should take a rect, not a rect, a scale and a "trajectoryVector" (I assume normalized). 

It is not normalized at this point yet. Normalization happens in TiledBackingStore::setTrajectoryVector.

> You should either split it in three method calls, or look for a more descriptive name.

I'll try to come up with a more descriptive name.

> 
> The scale of 1 passed for the page scale factor is really weird. I don't really understand why that would be correct. For example, a page has a scale of 0.3, the user resize the view, shouldn't the scale be re-computed for the viewport parameters?
> 

We only set the scale to 1 for the "legacy" webview (no fixed layout, i.e. traditional desktop behaviour as well as the QRawWebView).
For the QML WebView (with fixed layout) we recalculate each time something changes (see PageViewportController::syncVisibleContents).

> > Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:102
> > +    float m_lastSentPageScaleFactor;
> 
> float->double (the page scale factor is typed double).

Thanks for catching this.
Comment 24 Andras Becsi 2013-04-22 06:25:02 PDT
Created attachment 199021 [details]
Patch
Comment 25 Jocelyn Turcotte 2013-04-30 01:36:29 PDT
Comment on attachment 199021 [details]
Patch

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

> Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:131
> +void CoordinatedLayerTreeHostProxy::updateVisibleContentsState(const FloatRect& visibleContetsRect, double pageScaleFactor, const FloatPoint& trajectoryVector)

visibleConte*n*tsRect
You could also name the method updateContentsVisibility to match PageViewportController::didChangeContentsVisibility
Comment 26 Andras Becsi 2013-05-06 09:33:49 PDT
Created attachment 200707 [details]
Patch
Comment 27 EFL EWS Bot 2013-05-06 09:38:48 PDT
Comment on attachment 200707 [details]
Patch

Attachment 200707 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/431034
Comment 28 Andras Becsi 2013-05-06 09:44:18 PDT
Created attachment 200710 [details]
Patch
Comment 29 Jocelyn Turcotte 2013-05-07 08:22:56 PDT
Comment on attachment 200710 [details]
Patch

lgtm.
Benjamin, could you check again?
Comment 30 Andras Becsi 2013-05-30 03:00:27 PDT
Created attachment 203331 [details]
Patch
Comment 31 Andras Becsi 2013-05-30 03:01:05 PDT
(In reply to comment #30)
> Created an attachment (id=203331) [details]
> Patch

Updated to ToT.
Comment 32 EFL EWS Bot 2013-05-30 03:09:40 PDT
Comment on attachment 203331 [details]
Patch

Attachment 203331 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/673339
Comment 33 Andras Becsi 2013-05-30 03:12:16 PDT
Created attachment 203336 [details]
Patch
Comment 34 Anders Carlsson 2013-10-02 21:32:20 PDT
Comment on attachment 203336 [details]
Patch

Qt has been removed, clearing review flags.
Comment 35 Allan Sandfeld Jensen 2013-10-03 05:08:12 PDT
I don't see the flicker currently in qt5x2 branch. Is this patch still needed and should we apply it to branch?
Comment 36 Jocelyn Turcotte 2014-02-03 03:25:26 PST
=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.