The assertion is wrong, because it assumes that ImageDecoder::create() always returns a valid pointer, which is only true for the CG implementation. The non CG implementation can return nullptr if there isn't enough data to figure out the image format or if the image format is not supported. This is causing several crashes in the debug bots.
Created attachment 276626 [details]
Comment on attachment 276626 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=276626&action=review
> +bool ImageSource::tryEnsureDecoderIfNeeded(const SharedBuffer& data)
"try ensure" is not a good name, and "if needed" is more like "if possible".
(In reply to comment #2)
> Comment on attachment 276626 [details]
> View in context:
> > Source/WebCore/platform/graphics/ImageSource.cpp:74
> > +bool ImageSource::tryEnsureDecoderIfNeeded(const SharedBuffer& data)
> "try ensure" is not a good name, and "if needed" is more like "if possible".
My initial idea was to use try create instead, but normally try create methods return the created object or nullptr, but this one ensures it exists. So that's why I kept the ensure part. The "if possible" is already covered by try, if needed is not because ImageDecoder::create can fail, but because there's an early return in case the decoder has already been created. I added the if needed because I initially called it try create, but I agree the ensure also covers if needed. In any case, the ensure method is only called by setData() so I wonder if we really need an ensure method after all.
Btw, this is causing a lot of crashes in a our debug bot, so I would like tho fix this soon, to avoid the early exit.
Created attachment 276704 [details]
I think the code is simpler and clearer without the ensure method. In the end we can't ensure the decoder is created.
Comment on attachment 276704 [details]
Please wait one day in case Said has comments.
Committed r199764: <http://trac.webkit.org/changeset/199764>