Closed Bug 397209 Opened 17 years ago Closed 17 years ago

Very wide <button> triggers Cocoa exception "Can't cache image"

Categories

(Core :: Widget: Cocoa, defect)

x86
macOS
defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: cbarrett)

References

Details

(Keywords: testcase)

Attachments

(2 files)

Attached file testcase (deleted) —
Loading the testcase triggers: 2007-09-22 16:08:39.465 firefox-bin[7327] Can't cache image Because of bug 163260 / bug 340453, this leads to various bad things happening, including bogus free() calls. It's possible that this won't be a problem once bug 163260 and bug 340453 are fixed.
In this case we need to put a try/catch around -[NSImage lockFocus]. It is documented to throw an exception if it cannot create a representation to draw in. I wonder if we need to be doing offscreen drawing here -- perhaps we can adjust the CTM with a scale instead? Something to consider as we work on control drawing.
Attached patch fix v1.0 (deleted) — Splinter Review
This was bothering me, so I fixed it. There are two other places where we use lockFocus. http://mxr.mozilla.org/seamonkey/source/widget/src/cocoa/nsDragService.mm#260 This one should get fixed in the same way as this bug, IMO. http://mxr.mozilla.org/seamonkey/source/widget/src/cocoa/nsMenuItemIconX.mm#527 I don't understand why we're creating a CGImage and then drawing it into an NSImage. Can't we just create an NSBitmapImageRep instead? Those are both separate bugs though.
Assignee: joshmoz → cbarrett
Status: NEW → ASSIGNED
Attachment #282742 - Flags: review?(joshmoz)
Status: ASSIGNED → NEW
If this is trunk-only, should the newer @try/@catch stuff be used instead of the old-style NS_DURING, etc.?
Wevah, see bug 397381.
Attachment #282742 - Flags: superreview?(vladimir)
Attachment #282742 - Flags: review?(joshmoz)
Attachment #282742 - Flags: review+
Ah, thanks.
Attachment #282742 - Flags: superreview?(vladimir) → superreview+
Checking in widget/src/cocoa/nsNativeThemeCocoa.mm; /cvsroot/mozilla/widget/src/cocoa/nsNativeThemeCocoa.mm,v <-- nsNativeThemeCocoa.mm new revision: 1.63; previous revision: 1.62 done
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Now the testcase triggers ###!!! ASSERTION: Could not lock focus on offscreen buffer: '0', file /Users/jruderman/trunk/mozilla/widget/src/cocoa/nsNativeThemeCocoa.mm, line 195 which is better than a random crash later. I think it should be a warning rather than an assertion, though -- it's generally considered a bug if a page can trigger an assertion.
I changed this in my patch for bug 397381.
Crashtest checked in.
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: