Bug 25696

Summary: gtk directfb screen corruption on scrolling of webview
Product: WebKit Reporter: Luke Kenneth Casson Leighton <lkcl>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: andersca
Priority: P2 Keywords: Gtk
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
switches off fine-tuned paint logic, draws whole view, properly hyatt: review-

Description Luke Kenneth Casson Leighton 2009-05-11 09:22:36 PDT
got a bit of an issue with a directfb gtk app, using a gtk ScrollWindow and a webkit webview widget embedded in it.  mouse and keyboard scroll events give screen corruption when using VESA, IntelFB and also an embedded device (exact details unknown to me).  the amount and nature of the screen corruption that occurs is dependent on how much of the display area is being scrolled (by the mouse or the keyboard) but it varies from black artefacts, blue artefacts, both of width of the entire screen, and clearly distinguishable portions of the web page being viewed being shifted vertically by random offsets.

the corruption DOES NOT occur if:

* the vertical scrollbar position is set _manually_ using value adjustment on the scrollbar:
   m_VerticalAdjustment =
        gtk_scrolled_window_get_vadjustment(
             GTK_SCROLLED_WINDOW(scrolled_window));
   gtk_adjustment_set_value(m_VerticalAdjustment, val + INCR);

* the application is compiled as an X-Windows gtk app.  under these circumstances, no screen corruption occurs at all.


dpkg -l | grep directfb
ii  libcairo-directfb2                   1.8.6-2+b1                           The Cairo 2D vector graphics library DirectFB build (d
ii  libcairo-directfb2-dev               1.8.6-2+b1                           Development files for Cairo graphics library DirectFB 
ii  libdirectfb-1.2-0                    1.2.7-2                              direct frame buffer graphics - shared libraries
ii  libdirectfb-dev                      1.2.7-2                              direct frame buffer graphics library - development fil
ii  libdirectfb-extra                    1.2.7-2                              direct frame buffer graphics - extra providers
ii  libgtk-directfb-2.0-0                2.14.7-5                             The GTK+ graphical user interface library - DirectFB r
ii  libgtk-directfb-2.0-dev              2.14.7-5   


confirmed, also: the standard GtkLauncher application also shows the
exact same screen corruption on scrolling, using mouse or keyboard.
yet, the same GtkLauncher app when compiled using X-libs is fine.
Comment 1 Luke Kenneth Casson Leighton 2009-05-11 09:47:48 PDT
also related #22540 which also has screen corruption under gtk-directfb.
Comment 2 Luke Kenneth Casson Leighton 2009-05-15 10:13:22 PDT
Created attachment 30393 [details]
switches off fine-tuned paint logic, draws whole view, properly

thanks to paul for the guidance and for the leading work / patches on which this is based, paul, the code that you sent me has a bug where the scrollbars on a frame will go "blank" and disappear when you move the mouse over them. the reason is that the empty rect causes the return out of the paint function, prematurely, i fixed this by allowing the scrollbars always to be painted.
Comment 3 Dave Hyatt 2009-05-15 10:27:12 PDT
Umm why does this have a + on it?  There's nothing wrong with this cross-platform code, and you're changing other platform behavior.
Comment 4 Dave Hyatt 2009-05-15 10:36:50 PDT
Also, please don't mark bugs as reviewed if you are not a reviewer.  I'll give you the benefit of the doubt and assume you meant to set it to ? instead.

Anyway this patch is no good, since it just turns off blitting on scrolling completely.  This isn't something you should have to do.  All you're doing is working around bugs in your port's blitting implementation by doing this when you should be fixing those bugs.

The code that clips is also unnecessary.  As I said on webkit-dev, it is the responsibility of WebKit to clip to the document dirty rect before you even get into ScrollView paint.  Because you can have nested ScrollViews, repeatedly clipping to the document dirty rect is not something that these ScrollViews should need to do.  

Clipping to the visibleContentRect is necessary for each subframe ScrollView because the dirty rect may partially overlap the frame, but clipping to the document dirty rect should not be needed, as it should only happen once.  It is the WebView's responsibility to do this clipping in your WebKit port.
Comment 5 Dave Hyatt 2009-05-15 10:47:30 PDT
If it turns out your port has buggy blitting and you don't plan on solving the underlying problem, then in your platform-specific code you can always just set the can blit on scroll flag on the ScrollView to false.  That is the best way to disable all blitting without touching the cross-platform code.  Your scrolling performance is not going to be very good, though, if you do this, so I encourage you to try to figure out what is actually wrong with the underlying platform-specific blitting code (a bug in Cairo perhaps?).
Comment 6 Luke Kenneth Casson Leighton 2009-05-15 10:51:29 PDT
sorry, dave, i clicked the wrong button.

also - apologies, i do not know the difference between cross-platform code and other platform code.

all i know is that this works, and fixes a really serious show-stopper problem.  just disabling the blitting (with the #if 0) does not fix the problem.

it is unfortunately completely impractical to go digging around in gtk-directfb, it's _way_ too complex and time-consuming.

so - a minus review means it's unacceptable, and will thus remain unfixed.

for those people who will be searching desperately on the internet for ways to get their code out the door, and who do not have time to go fixing up gtk-directfb blitting bugs, or to find out what the bloody hell is going on, try this patch: disable the blitting, and also the bit which changes the rectangles.

i don't understand how it works, and i don't care: i just know that it works.  if you don't add the bit which changes the rectangles, you end up with one "flicker" (screen corruption) when you initially start scrolling a Frame, but only when both the horizontal and vertical scrollbars are both at 0, 0 scroll position.

thereafter, there is no further screen corruption, but even that one incident is too much.

patch the rectangles / clipping as shown in this patch and you will get no more flicker.


dave: paul has already mentioned that there is something wrong with the rectangle / clipping.

thank you for mentioning about the setting in scrollview, that will help other people.

right now, we have the solution, and there is not enough time or money to go hunting through a complex set of code like gtk-directfb or cairo-directfb.

so if anyone else would like to follow up on this, this patch highlights where the problems are, and at least provides a decent interim workaround.
Comment 7 Anders Carlsson 2015-04-24 11:52:33 PDT
Sounds like this is a bug in the DirectFB GTK+ backend.