RESOLVED CONFIGURATION CHANGED 5195
drawing with cacheDisplayInRect:toBitmapImageRep: doesn't trigger layout on Leopard
https://bugs.webkit.org/show_bug.cgi?id=5195
Summary drawing with cacheDisplayInRect:toBitmapImageRep: doesn't trigger layout on L...
Duncan Wilcox
Reported 2005-09-30 01:48:28 PDT
Updates to the DOM are rendered after 250ms: WebCore/khtml/xml/dom_docimpl.cpp:106:const int cLayoutScheduleThreshold = 250; When a WebView is used for the purpose of making screenshots (or perhaps even when less latency is desired), and the caller is manipulating the DOM and it knows that there are no more updates, a way to explicitly force the rendering of such changes would be desirable. The attached patch adds a "forceLayout" method to WebView, that flushes rendering by calling the underlying view's layout method. The attached DumpRenderTree-derived source demonstrates how a bitmap grabbed from a WebView is white without the forced layout, but is correct when the new method is called.
Attachments
patch (2.04 KB, patch)
2005-09-30 02:05 PDT, Duncan Wilcox
darin: review-
test case (2.80 KB, text/plain)
2005-09-30 02:07 PDT, Duncan Wilcox
no flags
patch (1.75 KB, patch)
2005-09-30 13:32 PDT, Duncan Wilcox
darin: review-
patch doing what Duncan and I discussed in email (2.18 KB, patch)
2005-10-04 13:26 PDT, Darin Adler
darin: review-
Tweaked test case (2.50 KB, text/plain)
2005-10-05 03:41 PDT, Duncan Wilcox
no flags
Duncan Wilcox
Comment 1 2005-09-30 02:05:13 PDT
Duncan Wilcox
Comment 2 2005-09-30 02:07:38 PDT
Created attachment 4103 [details] test case Build with something like: gcc -g -o dump dump.m -F<path to webkit build dir> -framework WebKit -framework WebCore -framework JavaScriptCore -framework Cocoa run with something like: DYLD_FRAMEWORK_PATH=<path to webkit build dir> ./dump
Darin Adler
Comment 3 2005-09-30 07:42:39 PDT
Comment on attachment 4102 [details] patch I don't think we want this. We do want to perform layout, bypassing the timer, but as a direct response to another method call that requires layout. For example, if there's a call to render the view into a buffer, then that call should force layout. We should only add a call like this to API if there is no way to accomplish this automatically, and I believe there is.
Darin Adler
Comment 4 2005-09-30 07:44:00 PDT
Now having looked at this test case, I think that we have to figure out how cacheDisplayInRect will force layout; I think there's code that tries to do it and is buggy.
Duncan Wilcox
Comment 5 2005-09-30 13:32:02 PDT
Created attachment 4119 [details] patch cacheDisplayInRect:toBitmapImageRep: doesn't trigger any notification, so I override it in WebView and force a layout before calling the super method.
Darin Adler
Comment 6 2005-10-02 20:32:35 PDT
Comment on attachment 4119 [details] patch I still don't think this is quite right. We should not be overriding this particular method, but rather the code path it follows that requires layout. In particular, we want this to work properly even if you make the call directly on the WebHTMLView. Is there really a need to support repainting without relayout? I don't think there is. Any painting should presumably create layout. The comment on the ChangeLog indicates an idea that somehow we would paint but still wait for a layout scheduling threshold; I think that's wrong.
Darin Adler
Comment 7 2005-10-04 13:26:31 PDT
Created attachment 4199 [details] patch doing what Duncan and I discussed in email
Duncan Wilcox
Comment 8 2005-10-05 03:41:41 PDT
Created attachment 4210 [details] Tweaked test case This slightly tweaked testcase demonstrates that Darin's latest patch fixes the problem.
Darin Adler
Comment 9 2005-10-05 10:05:27 PDT
Comment on attachment 4199 [details] patch doing what Duncan and I discussed in email Since Duncan confirms this code fixes the problem, lets get it reviewed and checked in.
Maciej Stachowiak
Comment 10 2005-10-09 16:35:14 PDT
Comment on attachment 4199 [details] patch doing what Duncan and I discussed in email r=me
Maciej Stachowiak
Comment 11 2005-10-09 17:01:02 PDT
Comment on attachment 4199 [details] patch doing what Duncan and I discussed in email Eric points out that this patch violats the style guidelines - single-line if blocks are put in braces and they should not be. Please fix before landing.
Adele Peterson
Comment 12 2005-10-11 12:08:11 PDT
mitz
Comment 13 2005-10-11 13:06:07 PDT
More accurately, the WebHTMLView patch attached to this bug resulted in subviews (such as form widgets) not being rendered in the pixel tests. The additional patch that fixed that (which is not in bugzilla) is what caused bug 5335.
Darin Adler
Comment 14 2005-10-12 07:35:29 PDT
Comment on attachment 4199 [details] patch doing what Duncan and I discussed in email I'll need to come up with a version of this that doesn't break drawing controls in the layout tests or drawing text field insertion points.
Darin Adler
Comment 15 2007-10-04 19:47:38 PDT
I suspect this is fixed in Leopard.
Darin Adler
Comment 16 2008-03-14 11:57:26 PDT
For those with access to Radar, <rdar://problem/5668489> is related Radar bug.
mitz
Comment 17 2008-07-14 17:18:47 PDT
(In reply to comment #15) > I suspect this is fixed in Leopard. And I think <http://trac.webkit.org/changeset/35176> fixed this for Tiger.
Duncan Wilcox
Comment 18 2008-07-14 23:46:44 PDT
I just tried the testcase on TOT on 10.5.4 and it is still not fixed.
John Sullivan
Comment 19 2008-07-31 10:38:12 PDT
This was fixed on Tiger a while back, but still not fixed on Leopard. I have a fix for Leopard.
John Sullivan
Comment 20 2008-07-31 10:50:55 PDT
Committed revision 35488.
mitz
Comment 21 2008-08-08 20:41:12 PDT
Unfortunately the Leopard fix had to be rolled out in <http://trac.webkit.org/changeset/35650>. I am re-opening the bug, but I am not sure there is a way to fix it in Leopard.
Ahmad Saleem
Comment 22 2022-08-09 05:49:55 PDT
Ryosuke Niwa
Comment 23 2022-08-09 10:37:20 PDT
We've re-rewriten code around this by now.
Radar WebKit Bug Importer
Comment 24 2022-08-09 10:38:18 PDT
Note You need to log in before you can comment on or make changes to this bug.