Bug 102801 - [WK2] Viewport meta tag broken after r134801
Summary: [WK2] Viewport meta tag broken after r134801
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mikhail Pozdnyakov
URL:
Keywords:
Depends on: 102971 103889
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-20 04:42 PST by Zeno Albisser
Modified: 2012-12-03 06:51 PST (History)
4 users (show)

See Also:


Attachments
preliminary patch. (2.49 KB, patch)
2012-11-20 10:26 PST, Mikhail Pozdnyakov
no flags Details | Formatted Diff | Diff
Patch (4.60 KB, patch)
2012-11-21 04:46 PST, Andras Becsi
no flags Details | Formatted Diff | Diff
Patch (4.58 KB, patch)
2012-11-21 04:56 PST, Andras Becsi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zeno Albisser 2012-11-20 04:42:41 PST
Loading any page that makes use of the viewport meta tag causes flickering and misplaced textures, when resizing the window.
In some cases textures are also being displayed upside down, right after loading the page. (without any resizing)
This might be an initialisation issue with a projection matrix or similar.
Comment 1 Kenneth Rohde Christiansen 2012-11-20 06:30:44 PST
How did you come to blame this commit? I don't see how it can affect this and everything works perfectly on EFL. Do you have some example pages that triggers this issue, and maybe screenshots?
Comment 2 Thiago Marcos P. Santos 2012-11-20 06:31:29 PST
Do you have a test page? Works fine here: http://people.opera.com/andreasb/viewport/ex02.html
Comment 3 Zeno Albisser 2012-11-20 08:22:07 PST
(In reply to comment #1)
> How did you come to blame this commit? I don't see how it can affect this and everything works perfectly on EFL. Do you have some example pages that triggers this issue, and maybe screenshots?
Git bisect.
Comment 5 Thiago Marcos P. Santos 2012-11-20 08:52:12 PST
(In reply to comment #4)
> (In reply to comment #2)
> > Do you have a test page? Works fine here: http://people.opera.com/andreasb/viewport/ex02.html
> 
> http://www.albisser.org/test/viewport.html

Indeed. This site is broken on Qt and EFL.
Comment 6 Mikhail Pozdnyakov 2012-11-20 10:26:30 PST
Created attachment 175242 [details]
preliminary patch.
Comment 7 Kenneth Rohde Christiansen 2012-11-20 10:33:54 PST
Comment on attachment 175242 [details]
preliminary patch.

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

> Source/WebKit2/ChangeLog:11
> +        Problem turned up as after m_rawAttributes.initialScale was set to '-1', the function
> +        WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(); was invoked from
> +        PageViewportController::didChangeViewportAttributes resetting also min and max scale
> +        factors to '-1'. 

Shouldn't we remove that call instead?
Comment 8 Andras Becsi 2012-11-20 10:41:30 PST
(In reply to comment #7)
> (From update of attachment 175242 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=175242&action=review
> 
> > Source/WebKit2/ChangeLog:11
> > +        Problem turned up as after m_rawAttributes.initialScale was set to '-1', the function
> > +        WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(); was invoked from
> > +        PageViewportController::didChangeViewportAttributes resetting also min and max scale
> > +        factors to '-1'. 
> 
> Shouldn't we remove that call instead?

No, that call is needed. I have a complete patch to fix this issue, uploading it soon.
Comment 9 Andras Becsi 2012-11-20 11:33:41 PST
The issue is actually a bit more complicated than I thought.

The main problem with leaving the initial scale -1 is that WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable is called by almost all ports (qt, efl, gtk, chromium) and it seems to me, that all callers assume that the scale values in the provided attributes are valid. This was also a reason why I previously introduced a bool flag for this case.

AFAICT the solution for this is one of the following:

- we change all the call sides to calculate the initial scale if it is <=0 and assert in restrictScaleFactorToInitialScaleIfNotUserScalable for initialScale

- we add a fallbackScale parameter to restrictScaleFactorToInitialScaleIfNotUserScalable and use it if initialScale <= 0

- we revert r134801

I think adding a new parameter (second solution) is the proper fix for this.

Kenneth, am I right here?
Comment 10 Kenneth Rohde Christiansen 2012-11-21 03:10:40 PST
(In reply to comment #9)
> The issue is actually a bit more complicated than I thought.
> 
> The main problem with leaving the initial scale -1 is that WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable is called by almost all ports (qt, efl, gtk, chromium) and it seems to me, that all callers assume that the scale values in the provided attributes are valid. This was also a reason why I previously introduced a bool flag for this case.
> 
> AFAICT the solution for this is one of the following:
> 
> - we change all the call sides to calculate the initial scale if it is <=0 and assert in restrictScaleFactorToInitialScaleIfNotUserScalable for initialScale
> 
> - we add a fallbackScale parameter to restrictScaleFactorToInitialScaleIfNotUserScalable and use it if initialScale <= 0
> 
> - we revert r134801
> 
> I think adding a new parameter (second solution) is the proper fix for this.
> 
> Kenneth, am I right here?

I would also go for number two. Basically restricting the min and max scale factors to the initial one is not part of the viewport meta algorithm, but more of an implementation detail.

Maybe just restrict to the minimum scale value then?
Comment 11 Mikhail Pozdnyakov 2012-11-21 03:37:08 PST
(In reply to comment #10)
> (In reply to comment #9)
> > The issue is actually a bit more complicated than I thought.
> > 
> > The main problem with leaving the initial scale -1 is that WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable is called by almost all ports (qt, efl, gtk, chromium) and it seems to me, that all callers assume that the scale values in the provided attributes are valid. This was also a reason why I previously introduced a bool flag for this case.
> > 
> > AFAICT the solution for this is one of the following:
> > 
> > - we change all the call sides to calculate the initial scale if it is <=0 and assert in restrictScaleFactorToInitialScaleIfNotUserScalable for initialScale
> > 
> > - we add a fallbackScale parameter to restrictScaleFactorToInitialScaleIfNotUserScalable and use it if initialScale <= 0
> > 
> > - we revert r134801
> > 
> > I think adding a new parameter (second solution) is the proper fix for this.
> > 
> > Kenneth, am I right here?
> 
> I would also go for number two. Basically restricting the min and max scale factors to the initial one is not part of the viewport meta algorithm, but more of an implementation detail.
> 
> Maybe just restrict to the minimum scale value then?
Also would like to add that initial scale is set to '-1' only for WK2 at the moment, think the same approach should be spread for all ports.
Comment 12 Kenneth Rohde Christiansen 2012-11-21 03:40:06 PST
(In reply to comment #11)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > The issue is actually a bit more complicated than I thought.
> > > 
> > > The main problem with leaving the initial scale -1 is that WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable is called by almost all ports (qt, efl, gtk, chromium) and it seems to me, that all callers assume that the scale values in the provided attributes are valid. This was also a reason why I previously introduced a bool flag for this case.
> > > 
> > > AFAICT the solution for this is one of the following:
> > > 
> > > - we change all the call sides to calculate the initial scale if it is <=0 and assert in restrictScaleFactorToInitialScaleIfNotUserScalable for initialScale
> > > 
> > > - we add a fallbackScale parameter to restrictScaleFactorToInitialScaleIfNotUserScalable and use it if initialScale <= 0
> > > 
> > > - we revert r134801
> > > 
> > > I think adding a new parameter (second solution) is the proper fix for this.
> > > 
> > > Kenneth, am I right here?
> > 
> > I would also go for number two. Basically restricting the min and max scale factors to the initial one is not part of the viewport meta algorithm, but more of an implementation detail.
> > 
> > Maybe just restrict to the minimum scale value then?
> Also would like to add that initial scale is set to '-1' only for WK2 at the moment, think the same approach should be spread for all ports.

There is outcommented code in ViewportArguments class to do this for everyone
Comment 13 Mikhail Pozdnyakov 2012-11-21 03:55:27 PST
(In reply to comment #12)
> (In reply to comment #11)
> > (In reply to comment #10)
> > > (In reply to comment #9)
> > > > The issue is actually a bit more complicated than I thought.
> > > > 
> > > > The main problem with leaving the initial scale -1 is that WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable is called by almost all ports (qt, efl, gtk, chromium) and it seems to me, that all callers assume that the scale values in the provided attributes are valid. This was also a reason why I previously introduced a bool flag for this case.
> > > > 
> > > > AFAICT the solution for this is one of the following:
> > > > 
> > > > - we change all the call sides to calculate the initial scale if it is <=0 and assert in restrictScaleFactorToInitialScaleIfNotUserScalable for initialScale
> > > > 
> > > > - we add a fallbackScale parameter to restrictScaleFactorToInitialScaleIfNotUserScalable and use it if initialScale <= 0
> > > > 
> > > > - we revert r134801
> > > > 
> > > > I think adding a new parameter (second solution) is the proper fix for this.
> > > > 
> > > > Kenneth, am I right here?
> > > 
> > > I would also go for number two. Basically restricting the min and max scale factors to the initial one is not part of the viewport meta algorithm, but more of an implementation detail.
> > > 
> > > Maybe just restrict to the minimum scale value then?
> > Also would like to add that initial scale is set to '-1' only for WK2 at the moment, think the same approach should be spread for all ports.
> 
> There is outcommented code in ViewportArguments class to do this for everyone
If we do not want to set initial scale to -1 for everyone hence we don't need to touch restrictScaleFactorToInitialScaleIfNotUserScalable, and my "preliminary patch" is acceptable, as it treats WK2 only which is only broken.
Comment 14 Kenneth Rohde Christiansen 2012-11-21 04:00:49 PST
Comment on attachment 175242 [details]
preliminary patch.

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

> Source/WebKit2/UIProcess/PageViewportController.cpp:220
>  
>      m_rawAttributes = newAttributes;
> +    if (m_rawAttributes.initialScale < 0)
> +        m_rawAttributes.initialScale = m_minimumScaleToFit;
>      WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
>  
>      m_allowsUserScaling = !!m_rawAttributes.userScalable;

Are you sure m_minimumScaleToFit is set correctly at this point? I believe this is called before contentSize is changed
Comment 15 Andras Becsi 2012-11-21 04:46:56 PST
Created attachment 175413 [details]
Patch
Comment 16 Andras Becsi 2012-11-21 04:56:31 PST
Created attachment 175414 [details]
Patch
Comment 17 Mikhail Pozdnyakov 2012-11-21 05:24:41 PST
Comment on attachment 175414 [details]
Patch

isn't it worth adding layout tests?
Comment 18 Andras Becsi 2012-11-21 05:56:40 PST
(In reply to comment #17)
> (From update of attachment 175414 [details])
> isn't it worth adding layout tests?

Layout tests do not use this code-path on Qt (fit-to-width), but extending the QML unit tests would be possible.
Comment 19 Kenneth Rohde Christiansen 2012-11-21 06:28:59 PST
(In reply to comment #18)
> (In reply to comment #17)
> > (From update of attachment 175414 [details] [details])
> > isn't it worth adding layout tests?
> 
> Layout tests do not use this code-path on Qt (fit-to-width), but extending the QML unit tests would be possible.

It should be possible to test that with layout tests now. Thiago Santos added support for that, though I am not sure the patch for Qt landed yet.
Comment 20 Thiago Marcos P. Santos 2012-11-21 06:44:12 PST
(In reply to comment #19)
> (In reply to comment #18)
> > (In reply to comment #17)
> > > (From update of attachment 175414 [details] [details] [details])
> > > isn't it worth adding layout tests?
> > 
> > Layout tests do not use this code-path on Qt (fit-to-width), but extending the QML unit tests would be possible.
> 
> It should be possible to test that with layout tests now. Thiago Santos added support for that, though I am not sure the patch for Qt landed yet.

Landed on bug 102811.
Comment 21 Andras Becsi 2012-11-21 07:04:20 PST
(In reply to comment #19)
> (In reply to comment #18)
> > (In reply to comment #17)
> > > (From update of attachment 175414 [details] [details] [details])
> > > isn't it worth adding layout tests?
> > 
> > Layout tests do not use this code-path on Qt (fit-to-width), but extending the QML unit tests would be possible.
> 
> It should be possible to test that with layout tests now. Thiago Santos added support for that, though I am not sure the patch for Qt landed yet.

Indeed, I missed that change.
Comment 22 Andras Becsi 2012-11-21 07:08:49 PST
Comment on attachment 175414 [details]
Patch

Clearing flags on attachment: 175414

Committed r135399: <http://trac.webkit.org/changeset/135399>
Comment 23 Andras Becsi 2012-11-21 07:08:55 PST
All reviewed patches have been landed.  Closing bug.
Comment 24 Andras Becsi 2012-11-21 07:28:36 PST
(In reply to comment #21)
> (In reply to comment #19)
> > (In reply to comment #18)
> > > (In reply to comment #17)
> > > > (From update of attachment 175414 [details] [details] [details] [details])
> > > > isn't it worth adding layout tests?
> > > 
> > > Layout tests do not use this code-path on Qt (fit-to-width), but extending the QML unit tests would be possible.
> > 
> > It should be possible to test that with layout tests now. Thiago Santos added support for that, though I am not sure the patch for Qt landed yet.
> 
> Indeed, I missed that change.

Since the preferred event handling behaviour for the flickable webview is not completely established yet, I think using fixed layout for layout testing is still somewhat unreliable on Qt, also because some initialization for Flickable depends on the onComponentComplete signal which is only emitted if the view was instantiated using QML.

So if we add layout tests that use the feature we should be careful with the behaviour.
As soon as we have free resources we're going to address these issues.
Comment 25 Thiago Marcos P. Santos 2012-11-21 12:10:56 PST
This patch caused regression on the EFL bots:

crash log for WebKitTestRunner (pid 4198):
STDOUT: <empty>
STDERR: ASSERTION FAILED: m_rawAttributes.initialScale > 0
STDERR: /home/buildslave-1/webkit-buildslave/efl-linux-64-debug-wk2/build/Source/WebKit2/UIProcess/PageViewportController.cpp(152) : void WebKit::PageViewportController::pageTransitionViewportReady()
STDERR: 1   0x7f6af371abfa WebKit::PageViewportController::pageTransitionViewportReady()
STDERR: 2   0x7f6af393e405 WebKit::PageClientDefaultImpl::pageTransitionViewportReady()
STDERR: 3   0x7f6af37703d5 WebKit::WebPageProxy::pageTransitionViewportReady()
STDERR: 4   0x7f6af397672a void CoreIPC::callMemberFunction<WebKit::WebPageProxy, void (WebKit::WebPageProxy::*)()>(CoreIPC::Arguments0 const&, WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)())
STDERR: 5   0x7f6af3972d36 void CoreIPC::handleMessage<Messages::WebPageProxy::PageTransitionViewportReady, WebKit::WebPageProxy, void (WebKit::WebPageProxy::*)()>(CoreIPC::MessageDecoder&, WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)())
STDERR: 6   0x7f6af396c149 WebKit::WebPageProxy::didReceiveWebPageProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&)
STDERR: 7   0x7f6af376b779 WebKit::WebPageProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&)
STDERR: 8   0x7f6af37ac895 WebKit::WebProcessProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&)
STDERR: 9   0x7f6af3694d04 CoreIPC::Connection::dispatchMessage(CoreIPC::MessageID, CoreIPC::MessageDecoder&)
STDERR: 10  0x7f6af3694e70 CoreIPC::Connection::dispatchMessage(CoreIPC::Connection::Message<CoreIPC::MessageDecoder>&)
STDERR: 11  0x7f6af36950bb CoreIPC::Connection::dispatchOneMessage()
STDERR: 12  0x7f6af369f25c WTF::FunctionWrapper<void (CoreIPC::Connection::*)()>::operator()(CoreIPC::Connection*)
STDERR: 13  0x7f6af369f062 WTF::BoundFunctionImpl<WTF::FunctionWrapper<void (CoreIPC::Connection::*)()>, void (CoreIPC::Connection*)>::operator()()
STDERR: 14  0x7f6afa840dca WTF::Function<void ()>::operator()() const
STDERR: 15  0x7f6af6d09baa WebCore::RunLoop::performWork()
STDERR: 16  0x7f6af77274c7 WebCore::RunLoop::wakeUpEvent(void*, void*, unsigned int)
STDERR: 17  0x7f6af2aa8621
STDERR: 18  0x7f6af2aa7571
STDERR: 19  0x7f6af2aa7ab7 ecore_main_loop_begin
STDERR: 20  0x43362b WTR::TestController::platformRunUntil(bool&, double)
STDERR: 21  0x41e94e WTR::TestController::runUntil(bool&, WTR::TestController::TimeoutDuration)
STDERR: 22  0x41de6b WTR::TestController::resetStateToConsistentValues()
STDERR: 23  0x425ac2 WTR::TestInvocation::invoke()
STDERR: 24  0x41e686 WTR::TestController::runTest(char const*)
STDERR: 25  0x41e7bf WTR::TestController::runTestingServerLoop()
STDERR: 26  0x41e859 WTR::TestController::run()
STDERR: 27  0x41c291 WTR::TestController::TestController(int, char const**)
STDERR: 28  0x4337c6 main
STDERR: 29  0x7f6af160876d __libc_start_main
STDERR: 30  0x41ac09
STDERR: LEAK: 4 WebCoreNode