Bug 98654 - [Qt][WTR] Do a forced repaint before generating pixel results
Summary: [Qt][WTR] Do a forced repaint before generating pixel results
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Balazs Kelemen
URL:
Keywords:
Depends on: 99354
Blocks: 95992 99463
  Show dependency treegraph
 
Reported: 2012-10-08 09:14 PDT by Balazs Kelemen
Modified: 2012-10-18 08:15 PDT (History)
10 users (show)

See Also:


Attachments
Patch (16.67 KB, patch)
2012-10-08 09:49 PDT, Balazs Kelemen
no flags Details | Formatted Diff | Diff
Patch (14.71 KB, patch)
2012-10-09 10:22 PDT, Balazs Kelemen
no flags Details | Formatted Diff | Diff
Patch (7.09 KB, patch)
2012-10-10 10:33 PDT, Balazs Kelemen
no flags Details | Formatted Diff | Diff
Patch (10.55 KB, patch)
2012-10-11 05:47 PDT, Balazs Kelemen
no flags Details | Formatted Diff | Diff
Patch (10.59 KB, patch)
2012-10-11 08:47 PDT, Balazs Kelemen
no flags Details | Formatted Diff | Diff
Patch (10.47 KB, patch)
2012-10-12 09:12 PDT, Balazs Kelemen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Balazs Kelemen 2012-10-08 09:14:30 PDT
The CoordinatedGraphics rendering backend needs an extra step of synchronisation in order to generate reliable pixel snapshots. Currently pixel results are generated at the end of the test run synchronously so we should slightly change WTR in order to allow delaying the dump after WKPageForceRepaint call us back.
Comment 1 Balazs Kelemen 2012-10-08 09:49:05 PDT
Created attachment 167549 [details]
Patch
Comment 2 Jocelyn Turcotte 2012-10-09 05:46:30 PDT
Comment on attachment 167549 [details]
Patch

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

> Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:117
> +    if (!s_watchDog)
> +        s_watchDog = new ForceRepaintDoneWatchDog(this);
> +    s_watchDog->start();

It feels like you're basically implementing what runUntil already does.
How about adding the extra async step to the chain of steps that we have in TestInvocation::invoke, keep textOutput, pixelResult and repaintRects in member variables, and use runUntil there to wait until the platform code obtained the dumped pixels, and then dump the results?

That would also prevent other platforms that want to use pixel tests with coordinated graphics classes to have to re-implement all this in their TestController.
Comment 3 Balazs Kelemen 2012-10-09 10:22:01 PDT
Created attachment 167777 [details]
Patch
Comment 4 Balazs Kelemen 2012-10-10 10:33:05 PDT
Created attachment 168028 [details]
Patch
Comment 5 Jocelyn Turcotte 2012-10-11 02:29:38 PDT
Comment on attachment 168028 [details]
Patch

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

> Tools/WebKitTestRunner/TestInvocation.h:57
> +    // Some platforms want to force a repaint before generating pixel result.
> +    static void forceRepaintDoneCallback(WKErrorRef, void* context)
> +    {
> +        reinterpret_cast<TestInvocation*>(context)->forceRepaintDone();
> +    }

This can go in the .cpp

> Tools/WebKitTestRunner/TestInvocation.h:58
> +    void forceRepaintDone();

Maybe put this under #if PLATFORM(QT)?

> Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:78
> +    TestController::shared().runUntil(m_gotRepaint, TestController::ShortTimeout);

This is using the same instance of TestController and are running a runUntil on top of another runUntil, including the full stack up to didReceiveMessageFromInjectedBundle.
If it really is working well this might be fine since it's simpler for now, but if it starts smelling bad we could pick parts of your last patch to have this runUntil running after the previous one is finished.

> Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:81
> +    if (m_gotRepaint) {

In which cases is this false, can't we just assert?
Comment 6 Balazs Kelemen 2012-10-11 02:37:30 PDT
> This is using the same instance of TestController and are running a runUntil on top of another runUntil, including the full stack up to didReceiveMessageFromInjectedBundle.
> If it really is working well this might be fine since it's simpler for now, but if it starts smelling bad we could pick parts of your last patch to have this runUntil running after the previous one is finished.

Ok, I'm going to check how it affects performance and whether a nested runLoop could work for all platforms.

> 
> > Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:81
> > +    if (m_gotRepaint) {
> 
> In which cases is this false, can't we just assert?

It is false if smg is wrong with the synchronisation. Given that it is a bit fragile according to our experiences in connection this work, and that we want to run this on bots I believe it's better to handle this case gracefully.
Comment 7 Balazs Kelemen 2012-10-11 05:47:15 PDT
Created attachment 168202 [details]
Patch
Comment 8 Jocelyn Turcotte 2012-10-11 06:20:36 PDT
Comment on attachment 168202 [details]
Patch

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

> Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:70
> +    reinterpret_cast<TestInvocation*>(context)->m_gotRepaint = true;

static_cast

> Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:90
> +    } else {
> +        // The test harness expects an image so we output an empty one.
> +        WKRect windowRect = TestController::shared().mainWebView()->windowFrame();
> +        image = QImage(QSize(windowRect.size.width, windowRect.size.height), QImage::Format_ARGB32_Premultiplied);
> +        image.fill(Qt::black);
> +    }

That case is pretty silent, we could try to make it obvious from the test results by printing it red. We could also print an error if you end up delaying the stderr #EOF like you proposed.
Comment 9 Balazs Kelemen 2012-10-11 08:47:16 PDT
Created attachment 168235 [details]
Patch
Comment 10 Balazs Kelemen 2012-10-11 08:49:04 PDT
> > Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:70
> > +    reinterpret_cast<TestInvocation*>(context)->m_gotRepaint = true;
> 
> static_cast

Fixed.

> 
> > Tools/WebKitTestRunner/qt/TestInvocationQt.cpp:90
> > +    } else {
> > +        // The test harness expects an image so we output an empty one.
> > +        WKRect windowRect = TestController::shared().mainWebView()->windowFrame();
> > +        image = QImage(QSize(windowRect.size.width, windowRect.size.height), QImage::Format_ARGB32_Premultiplied);
> > +        image.fill(Qt::black);
> > +    }
> 
> That case is pretty silent, we could try to make it obvious from the test results by printing it red. We could also print an error if you end up delaying the stderr #EOF like you proposed.

Ok, changed it to red. Later we can add the error message.
Comment 11 Balazs Kelemen 2012-10-12 01:44:20 PDT
Comment on attachment 168235 [details]
Patch

Clearing flags on attachment: 168235

Committed r131160: <http://trac.webkit.org/changeset/131160>
Comment 12 Balazs Kelemen 2012-10-12 01:44:25 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Csaba Osztrogonác 2012-10-12 04:25:00 PDT
(In reply to comment #11)
> (From update of attachment 168235 [details])
> Clearing flags on attachment: 168235
> 
> Committed r131160: <http://trac.webkit.org/changeset/131160>

It made layout testing extremely slow - http://build.webkit.sed.hu/builders/x86-64%20Linux%20Qt%20Release%20WebKit2%20%28Amazon%20EC2%29/builds/9671/steps/layout-test

2.5 hours - 9800 tests :((((
Comment 14 WebKit Review Bot 2012-10-12 04:56:37 PDT
Re-opened since this is blocked by bug 99163
Comment 15 Balazs Kelemen 2012-10-12 05:02:43 PDT
(In reply to comment #14)
> Re-opened since this is blocked by bug 99163

Sorry, I realized that it should not be landed without the patch in bug 95992 because it makes pixel and ref tests time out.
Comment 16 Balazs Kelemen 2012-10-12 09:06:31 PDT
Let's do one more iteration as I realized that I am leaking memory.
Comment 17 Balazs Kelemen 2012-10-12 09:12:12 PDT
Created attachment 168433 [details]
Patch

Fixed memory leak by correctly adopting the snapshot image.
Comment 18 Balazs Kelemen 2012-10-15 10:17:24 PDT
Landed in http://trac.webkit.org/changeset/131306
Comment 19 WebKit Review Bot 2012-10-15 12:47:03 PDT
Re-opened since this is blocked by bug 99354
Comment 20 Csaba Osztrogonác 2012-10-15 12:56:41 PDT
(In reply to comment #18)
> Landed in http://trac.webkit.org/changeset/131306

Rolled out, because it broke layout testing again - http://trac.webkit.org/changeset/131339

I stopped the test after 3 hours 8 minutes (after an editing 
test). Normally all tests take only 25 minutes.
Comment 22 Balazs Kelemen 2012-10-18 08:15:45 PDT
Landed again in http://trac.webkit.org/changeset/131725