Bug 154283 - [GTK] scroll with transparent background not repainted after scrollY >= 32768
Summary: [GTK] scroll with transparent background not repainted after scrollY >= 32768
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: PC Linux
: P2 Normal
Assignee: Gwang Yoon Hwang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-16 02:38 PST by Jérémy Lal
Modified: 2017-02-16 05:48 PST (History)
9 users (show)

See Also:


Attachments
Patch (2.45 KB, patch)
2016-02-22 20:52 PST, Gwang Yoon Hwang
no flags Details | Formatted Diff | Diff
Patch (2.48 KB, patch)
2016-02-23 20:55 PST, Gwang Yoon Hwang
no flags Details | Formatted Diff | Diff
Patch (3.42 KB, patch)
2016-05-01 07:59 PDT, Gwang Yoon Hwang
no flags Details | Formatted Diff | Diff
Patch (4.00 KB, patch)
2017-02-09 08:51 PST, Miguel Gomez
no flags Details | Formatted Diff | Diff
Patch (4.04 KB, patch)
2017-02-09 09:17 PST, Miguel Gomez
no flags Details | Formatted Diff | Diff
Patch (4.08 KB, patch)
2017-02-09 09:35 PST, Miguel Gomez
no flags Details | Formatted Diff | Diff
Patch (7.94 KB, patch)
2017-02-16 04:49 PST, Miguel Gomez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jérémy Lal 2016-02-16 02:38:57 PST
Using webkit2gtk 2.10.6
This can be tested with MiniBrowser on http://expressjs.com/en/4x/api.html

Setting document.documentElement.style.background = "white" hides the issue.
Comment 1 Michael Catanzaro 2016-02-16 07:00:17 PST
Nice bug report, this is pretty serious.

(I know we have a duplicate report of this somewhere, but I failed to find it.)
Comment 2 Carlos Garcia Campos 2016-02-17 07:49:07 PST
This is a known issue of cairo, we are hitting its coordinate space limit. When the scrollY >= 32768 the current transformation matrix has a y coordinate that is out of the coordinate space. This document paints the background using an image that is drawn with drawTiledImage. At that scroll point we simply don't render anything as background and the target surface ends up with a transparent background. Forcing the background to white fixes the problem because in that case we just fill the surface with white before rendering the contents. We should be able to workaround this by translating coordinates, but we need someone with more experience in graphics to help here.
Comment 3 Gwang Yoon Hwang 2016-02-22 20:52:52 PST
Created attachment 271986 [details]
Patch
Comment 4 Gwang Yoon Hwang 2016-02-23 20:55:04 PST
Created attachment 272084 [details]
Patch
Comment 5 Gwang Yoon Hwang 2016-02-23 20:57:49 PST
Ah, I omitted a multiplication from my local changes. That's why my previous patch didn't work.

I updated the patch and it works. :)
Comment 6 Gwang Yoon Hwang 2016-02-23 23:56:40 PST
Not fixed yet when we are using threaded compositor.
Comment 7 Carlos Garcia Campos 2016-02-24 03:25:31 PST
(In reply to comment #6)
> Not fixed yet when we are using threaded compositor.

That's not a priority at the moment, so please file a bug report for the threaded compositor blocking the meta one.
Comment 8 Carlos Garcia Campos 2016-02-24 03:30:21 PST
Comment on attachment 272084 [details]
Patch

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

Thanks! this patch fixes the test cases I was using, but seems to break other things. For example, go to www.amazon.com and move the cursor to "Hello, sign in Your Account". See the background of the Sign in button in the drop down menu, it's even worse if you hover it. I've seen similar effects in other websites.

> Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp:209
> +    cairo_matrix_t ctm;
> +    double dx = 0, dy = 0;
> +    cairo_get_matrix(cr, &ctm);
> +    cairo_matrix_transform_point(&ctm, &dx, &dy);
> +
> +    if (dx < 0)
> +        dx = std::floor(std::abs(dx / tileRect.width())) * tileRect.width();
> +    if (dy < 0)
> +        dy = std::floor(std::abs(dy / tileRect.height())) * tileRect.height();
> +    cairo_translate(cr, dx, dy);

We should add a comment here explaining we are doing this here because of the cairo limitation.
Comment 9 Michael Catanzaro 2016-02-26 16:48:00 PST
Comment on attachment 272084 [details]
Patch

Needs to not break Amazon :)
Comment 10 Carlos Garcia Campos 2016-02-29 09:49:13 PST
It seems that the problem is when the destination rectangle is not at 0, 0 because we translate to dx, dy, but the destination rectangle is for the previous CTM. So, doing 

cairo_rectangle(cr, destRect.x() - dx, destRect.y() - dy, destRect.width(), destRect.height()); 

seems to fix the translation problem, but now the problem is that there's also a phase, so the pattern matrix is also translated. If I adjust the pattern matrix it works, but then again we can end up with a pattern matrix out of the cairo limits, so I guess I'm basically undoing the previous thing. the think is that I don't manage to make both cases work, so I'm lost again.
Comment 11 Gwang Yoon Hwang 2016-05-01 07:59:02 PDT
Created attachment 277862 [details]
Patch
Comment 12 Gwang Yoon Hwang 2016-05-01 08:11:22 PDT
(In reply to comment #10)
> It seems that the problem is when the destination rectangle is not at 0, 0
> because we translate to dx, dy, but the destination rectangle is for the
> previous CTM. So, doing 
> 
> cairo_rectangle(cr, destRect.x() - dx, destRect.y() - dy, destRect.width(),
> destRect.height()); 
> 
> seems to fix the translation problem, but now the problem is that there's
> also a phase, so the pattern matrix is also translated. If I adjust the
> pattern matrix it works, but then again we can end up with a pattern matrix
> out of the cairo limits, so I guess I'm basically undoing the previous
> thing. the think is that I don't manage to make both cases work, so I'm lost
> again.

I made a new patch and I believe I fixed for most of the cases.

I found out that I didn't handle dx and dy if it is positive. Also, I didn't handle scale component of CTM.
And as you pointed out, we need to adjust destRect, too.
For the phase, I don't think we need to adjust the phase unless the size of tile exceeds the limit of Pixman.
Can you share the case which has a problem with a phase?
Comment 13 Gwang Yoon Hwang 2016-05-02 07:49:35 PDT
(In reply to comment #12)
> (In reply to comment #10)
> > It seems that the problem is when the destination rectangle is not at 0, 0
> > because we translate to dx, dy, but the destination rectangle is for the
> > previous CTM. So, doing 
> > 
> > cairo_rectangle(cr, destRect.x() - dx, destRect.y() - dy, destRect.width(),
> > destRect.height()); 
> > 
> > seems to fix the translation problem, but now the problem is that there's
> > also a phase, so the pattern matrix is also translated. If I adjust the
> > pattern matrix it works, but then again we can end up with a pattern matrix
> > out of the cairo limits, so I guess I'm basically undoing the previous
> > thing. the think is that I don't manage to make both cases work, so I'm lost
> > again.
> 
> I made a new patch and I believe I fixed for most of the cases.
> 
> I found out that I didn't handle dx and dy if it is positive. Also, I didn't
> handle scale component of CTM.
> And as you pointed out, we need to adjust destRect, too.
> For the phase, I don't think we need to adjust the phase unless the size of
> tile exceeds the limit of Pixman.
> Can you share the case which has a problem with a phase?

Ah, I found out the problem at the border-image.
Comment 14 Michael Catanzaro 2017-01-27 16:48:17 PST
This can also be reproduced on http://backbonejs.org/.
Comment 15 Miguel Gomez 2017-02-09 08:51:39 PST
Created attachment 301043 [details]
Patch
Comment 16 Carlos Garcia Campos 2017-02-09 08:59:39 PST
Comment on attachment 301043 [details]
Patch

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

wow, thank you very much for working on this! Let's try this. Please consider adding a test in a follow up patch

> Source/WebCore/ChangeLog:19
> +        No new tests.

Sounds like we could add a new test for this?
Comment 17 Miguel Gomez 2017-02-09 09:17:48 PST
Created attachment 301047 [details]
Patch
Comment 18 WebKit Commit Bot 2017-02-09 09:28:22 PST
Comment on attachment 301047 [details]
Patch

Rejecting attachment 301047 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-02', 'validate-changelog', '--check-oops', '--non-interactive', 301047, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

ChangeLog entry in Source/WebCore/ChangeLog contains OOPS!.

Full output: http://webkit-queues.webkit.org/results/3050167
Comment 19 Miguel Gomez 2017-02-09 09:35:10 PST
Created attachment 301051 [details]
Patch
Comment 20 WebKit Commit Bot 2017-02-09 10:12:55 PST
Comment on attachment 301051 [details]
Patch

Clearing flags on attachment: 301051

Committed r211967: <http://trac.webkit.org/changeset/211967>
Comment 21 WebKit Commit Bot 2017-02-09 10:13:00 PST
All reviewed patches have been landed.  Closing bug.
Comment 22 Jérémy Lal 2017-02-09 14:42:08 PST
Happy to confirm the bug is no longer visible in the case i reported.
Comment 23 Carlos Garcia Campos 2017-02-14 23:39:46 PST
Reverted r211967 for reason:

Caused rendering issues in HiDPI

Committed r212346: <http://trac.webkit.org/changeset/212346>
Comment 24 Miguel Gomez 2017-02-16 04:49:30 PST
Created attachment 301744 [details]
Patch
Comment 25 Carlos Garcia Campos 2017-02-16 05:04:23 PST
Comment on attachment 301744 [details]
Patch

Let's try again!
Comment 26 WebKit Commit Bot 2017-02-16 05:48:47 PST
Comment on attachment 301744 [details]
Patch

Clearing flags on attachment: 301744

Committed r212431: <http://trac.webkit.org/changeset/212431>
Comment 27 WebKit Commit Bot 2017-02-16 05:48:52 PST
All reviewed patches have been landed.  Closing bug.