WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
VERIFIED FIXED
6219
Perf regression: -[NSImage initWithData:] called repeatedly while moving the cursor over an image
https://bugs.webkit.org/show_bug.cgi?id=6219
Summary
Perf regression: -[NSImage initWithData:] called repeatedly while moving the ...
mitz
Reported
2005-12-23 07:14:46 PST
Each call to -[WebView elementAtPoint:] for a point inside an image entails a call to -[NSImage initWithData:] to fill the WebElementImageKey. This results in pretty high CPU usage when simply moving the mouse cursor across a big image. See the testcase for example. I think this started with the changes to QPixmap when
bug 5689
was fixed.
Attachments
Testcase
(151 bytes, text/html)
2005-12-23 07:15 PST
,
mitz
no flags
Details
Lame patch
(1.76 KB, patch)
2005-12-31 04:30 PST
,
mitz
darin
: review-
Details
Formatted Diff
Diff
Change pixmap() to return a const QPixmap&
(2.48 KB, patch)
2006-01-01 01:43 PST
,
mitz
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
mitz
Comment 1
2005-12-23 07:15:43 PST
Created
attachment 5250
[details]
Testcase
Eric Seidel (no email)
Comment 2
2005-12-23 10:03:52 PST
Great catch.
mitz
Comment 3
2005-12-31 04:30:48 PST
Created
attachment 5395
[details]
Lame patch With this patch, initWithData: will still be called once per image, which is almost always a waste of time. The non-lame approach, I think, is to use an NSImage subclass or a proxy that does lazy instantiation as the value of WebElementImageKey in the element dictionary.
Darin Adler
Comment 4
2005-12-31 18:14:17 PST
Comment on
attachment 5395
[details]
Lame patch Better to just change the pixmap() function to return a const QPixmap& -- that would do the trick.
mitz
Comment 5
2006-01-01 01:43:52 PST
Created
attachment 5406
[details]
Change pixmap() to return a const QPixmap& I really ought to learn that "programming" thing.
mitz
Comment 6
2006-01-01 01:49:57 PST
Comment on
attachment 5406
[details]
Change pixmap() to return a const QPixmap& Maybe there should be a FIXME in WebHTMLView where it creates the NSImage saying that it would be better to delay the actual NSImage instantiation? It seems that in an overwhelming majority of cases, the WebElementImageKey isn't used. Another option, instead of using a proxy or an NSImage subclass, is to use an NSMutableDictionary subclass for the result of -[WebHTMLView elementAtPoint:] that knows how to generate the value of the WebElementImageKey from the WebCoreElementImageRendererKey.
mitz
Comment 7
2006-01-01 07:21:41 PST
Okay, the last suggestion was really stupid.
Darin Adler
Comment 8
2006-01-02 14:35:51 PST
Comment on
attachment 5406
[details]
Change pixmap() to return a const QPixmap& Looks fine, r=me. Good suggestions about implementing our own Objective-C dictionary so we can compute this lazily.
Darin Adler
Comment 9
2006-01-02 14:43:14 PST
Mitz's last suggestion was *not* stupid. We can't create an NSMutableDictionary subclass, but we can make our own dictionary class that's part of the NSDictionary "class cluster". And that is indeed the best way to fix this "for real". And yes, I think the the FIXME is a good idea.
Maciej Stachowiak
Comment 10
2006-01-03 00:35:56 PST
Agreed, in fact some APIs in AppKit return custom NSDictionary subclasses.
Darin Adler
Comment 11
2006-01-07 10:20:10 PST
To be even more specific, we should use an NSDictionary subclass. It only has to implement the three methods count, objectForKey:, and keyEnumerator. And the keyEnumerator will be an NSEnumerator that only has to implement nextObject. We should make sure there's a method on DOMNode or DOMElement for each of the properties and then we can just map the dictionary key to a selector and call it on the DOMElement.
mitz
Comment 12
2006-02-25 00:12:49 PST
See
bug 7450
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug