Bug 20786 - ASSERT in BitmapImage::draw when an image is scaled and clipped
Summary: ASSERT in BitmapImage::draw when an image is scaled and clipped
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-11 09:51 PDT by Chris Marrin
Modified: 2008-09-15 10:11 PDT (History)
2 users (show)

See Also:


Attachments
Patch to fix bug (1.35 KB, patch)
2008-09-11 09:58 PDT, Chris Marrin
mitz: review+
Details | Formatted Diff | Diff
Testcase (121.99 KB, application/zip)
2008-09-11 11:01 PDT, Chris Marrin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Marrin 2008-09-11 09:51:50 PDT
There is an assert at ImageCG.cpp:166 which is wrong and causes the assert to
be hit unnecessarily. Unzip the attached file and open the index.html file.
Then reload over and over again pretty quickly. Sometimes on my machine it can
take 60 reloads to hit the bug. But it will eventually happen.

The problem is that the CGImageCreateWithImageInRect() function calls
CGRectIntegral() to modify the srcRect before creating the image. Then the
ASSERT calls CGImageGetHeight() to get the integral height of the image, but
subtracts srcRect.y() from currHeight (which is also an integral height) to do
the comparison. But srcRect.y() is not an integral position, so the test fails. 

Changing the test to:

    ASSERT(CGImageGetHeight(image) == currHeight -
CGRectIntegral(srcRect).origin.y);

converts srcRect.y() into an integral value and causes the test to succeed. The
attached patch does this.
Comment 1 Chris Marrin 2008-09-11 09:52:15 PDT
We are trimming down the test case now, will post soon
Comment 2 Chris Marrin 2008-09-11 09:58:21 PDT
Created attachment 23352 [details]
Patch to fix bug
Comment 3 Chris Marrin 2008-09-11 11:01:16 PDT
Created attachment 23354 [details]
Testcase
Comment 4 mitz 2008-09-11 15:12:38 PDT
Comment on attachment 23352 [details]
Patch to fix bug

r=me if you also change
currHeight - srcRect.y() to CGImageGetHeight(image) on the next line
Comment 5 Simon Fraser (smfr) 2008-09-15 10:11:14 PDT
Committed r36446
	M	WebCore/platform/graphics/cg/ImageCG.cpp
	M	WebCore/ChangeLog
r36446 = da60464c4f95326036ace5eafb4dd562990c80c2 (trunk)