Closed
Bug 515240
Opened 16 years ago
Closed 16 years ago
"ASSERTION: MakePlatformFont called with null data ptr"
Categories
(Core :: Graphics, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jruderman, Assigned: jfkthame)
References
Details
(Keywords: assertion)
Attachments
(3 files)
209 bytes,
text/html
|
Details | |
1.80 KB,
patch
|
jtd
:
review-
|
Details | Diff | Splinter Review |
1013 bytes,
patch
|
Details | Diff | Splinter Review |
Loading http://www.machinima.org/machinima-faq.html triggers some assertions:
###!!! ASSERTION: MakePlatformFont called with null data ptr: 'aFontData && aLength != 0', file /Users/jruderman/central/gfx/thebes/src/gfxMacPlatformFontList.mm, line 699
###!!! ASSERTION: null font data: 'aFontData && aFontDataLength != 0', file /Users/jruderman/central/gfx/thebes/src/gfxFontUtils.cpp, line 702
WARNING: invalid font (insufficient data): file /Users/jruderman/central/gfx/thebes/src/gfxFontUtils.cpp, line 708
WARNING: downloaded font error, invalid font data for (screenfox9): file /Users/jruderman/central/gfx/thebes/src/gfxMacPlatformFontList.mm, line 710
Assignee | ||
Comment 1•16 years ago
|
||
This looks pretty benign. The site links to a couple of EOT fonts, but doesn't provide a format hint, so our expected behavior would be to download them and then discover we don't support their format (generating an "invalid font data..." warning in a debug build).
However, it seems that the fonts are not actually present at that site, yet it doesn't respond with a 404 or similar error, it simply gives us a zero-byte response. So that zero-length chunk of data gets passed to MakePlatformFont when the load "completes", and that's triggering the assertions (but we then correctly determine that it's not a usable font, and continue).
We could either check earlier for a completely empty response to the font load request, or remove those non-zero length checks on the grounds that ValidateSfntHeaders will quickly reject a zero-length font anyway.
Assignee | ||
Comment 2•16 years ago
|
||
Assignee | ||
Comment 3•16 years ago
|
||
With this patch, the zero-length font data in the testcase (and the original URL) is handled correctly, resulting in two warnings, "invalid font (insufficient data)" and then "downloaded font error, invalid font data for (<fontname>)" but no assertions.
Assignee: nobody → jfkthame
Attachment #399353 -
Flags: review?(jdaggett)
Comment 4•16 years ago
|
||
Comment on attachment 399353 [details] [diff] [review]
remove over-zealous assertions (zero length data is handled safely)
I think the asssertions are fine, the error should be handled one level up.
Attachment #399353 -
Flags: review?(jdaggett) → review-
Comment 5•16 years ago
|
||
No need to try to validate a null data ptr, just detect that and take the download failure case immediately.
Attachment #399377 -
Flags: review?(jfkthame)
Assignee | ||
Comment 6•16 years ago
|
||
It doesn't seem right to treat a successful download of a zero-length file (which, as far as we can tell, is the case here) as being a download failure, which is what happens if you test for aLength != 0 here. Testing for non-null aFontData would be fine; if the pointer is null, we don't want to do anything further with it.
It's true that zero-length data cannot be a valid font, but that would also be true if the download is one byte long, or two, or three..... there's no reason to treat the zero-length case specially at this level. The first thing we do in ValidateSfntHeaders is to check that we've got enough data to meaningfully start examining it.
So I still think those assertions are "over-zealous". We don't need the assertion in gfxMacPlatformFontList::MakePlatformFont at all (and note that we don't have one in the equivalent place on other platforms), as gfxFontUtils::ValidateSFNTHeaders asserts exactly the same conditions; and the assertion there should check that the pointer is non-null (I left that part in place), but there is no reason for it to assert anything about aFontDataLength, that's simply part of what we check to find out whether we've got usable font data.
So please reconsider the patch I suggested; I'm arguing that there is (a) no need for the current duplication of the assertion, and (b) no reason to assert if the download has given us a valid data pointer that just happens to have too little data (including zero bytes) to be a usable font. That's something we handle correctly without an assertion.
If you want to check for that particular special case earlier as well, I suppose that's ok; however, the length == 0 case should be reported as "insufficent data" rather than as a download error. But I don't see any real benefit to adding that check in OnLoadComplete, given that we handle it fine already.
Assignee | ||
Comment 7•16 years ago
|
||
This is resolved as a side-effect of bug 507970 (WOFF font support): the bad (zero-length) download is rejected by the new gfxUserFontSet.cpp function PrepareOpenTypeData, which determines that it cannot be valid font data. It prints an NS_WARNING (in debug builds), and the request is safely discarded.
Updated•15 years ago
|
Attachment #399377 -
Flags: review?(jfkthame)
You need to log in
before you can comment on or make changes to this bug.
Description
•