Bug 225183

Summary: Handle case where decoding of image lead to an empty one.
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: New BugsAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, eric.carlson, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, jer.noble, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 225999    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Jean-Yves Avenard [:jya]
Reported 2021-04-28 20:23:37 PDT
Handle case where decoding of image lead to an empty one.
Attachments
Patch (1.69 KB, patch)
2021-04-28 20:48 PDT, Jean-Yves Avenard [:jya]
no flags
Patch (3.87 KB, patch)
2021-04-28 21:10 PDT, Jean-Yves Avenard [:jya]
no flags
Patch (2.73 KB, patch)
2021-04-29 17:57 PDT, Jean-Yves Avenard [:jya]
no flags
Jean-Yves Avenard [:jya]
Comment 1 2021-04-28 20:25:22 PDT
Jean-Yves Avenard [:jya]
Comment 2 2021-04-28 20:48:00 PDT
Jean-Yves Avenard [:jya]
Comment 3 2021-04-28 21:10:42 PDT
Eric Carlson
Comment 4 2021-04-29 10:09:57 PDT
Comment on attachment 427328 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427328&action=review > Source/WebCore/Modules/mediasession/MediaMetadata.cpp:184 > + // Empty image; ignore. Nit: I don't think this comment is necessary. > Source/WebCore/html/MediaElementSession.cpp:1160 > + ASSERT(sessionMetadata->artworkImage()->data()); > artwork = NowPlayingInfoArtwork { sessionMetadata->artworkSrc(), sessionMetadata->artworkImage()->mimeType(), sessionMetadata->artworkImage()->data() }; Is there any reason to create the artwork if `sessionMetadata->artworkImage()->data()` is NULL? > Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm:314 > + ASSERT(nowPlayingInfo.artwork->imageData); > auto nsArtwork = nowPlayingInfo.artwork->imageData->createNSData(); This will crash in a release build, so either the assert isn't necessary or we should not try to create the artwork if the image data is NULL.
Jean-Yves Avenard [:jya]
Comment 5 2021-04-29 17:26:55 PDT
Comment on attachment 427328 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427328&action=review >> Source/WebCore/html/MediaElementSession.cpp:1160 >> artwork = NowPlayingInfoArtwork { sessionMetadata->artworkSrc(), sessionMetadata->artworkImage()->mimeType(), sessionMetadata->artworkImage()->data() }; > > Is there any reason to create the artwork if `sessionMetadata->artworkImage()->data()` is NULL? This is the point of the assert. An Image received here *must* have a SharedBuffer attached. It is an error if there's not. This is the core of the change. But Jer suggested I use a Ref rather than a RefPtr in NowPlayingInfoArtwork structure, however the code relies on the ability to set the value to a null pointer to indicate that the cached image should be used instead. So it would need to be made an Optional<Ref<SharedBuffer>> which is pretty much what a RefPtr is.
Jean-Yves Avenard [:jya]
Comment 6 2021-04-29 17:57:15 PDT
EWS
Comment 7 2021-04-29 18:42:27 PDT
Committed r276827 (237182@main): <https://commits.webkit.org/237182@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427393 [details].
Eric Carlson
Comment 8 2021-04-30 07:49:37 PDT
(In reply to Jean-Yves Avenard [:jya] from comment #5) > Comment on attachment 427328 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=427328&action=review > > >> Source/WebCore/html/MediaElementSession.cpp:1160 > >> artwork = NowPlayingInfoArtwork { sessionMetadata->artworkSrc(), sessionMetadata->artworkImage()->mimeType(), sessionMetadata->artworkImage()->data() }; > > > > Is there any reason to create the artwork if `sessionMetadata->artworkImage()->data()` is NULL? > > This is the point of the assert. An Image received here *must* have a > SharedBuffer attached. It is an error if there's not. > > This is the core of the change. Right. My point was that NowPlayingInfoArtwork without image data is useless, ASSERTing in a debug build is good but why create the NowPlayingInfoArtwork in a release build?
Jean-Yves Avenard [:jya]
Comment 9 2021-04-30 15:19:16 PDT
Comment on attachment 427328 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427328&action=review >>>> Source/WebCore/html/MediaElementSession.cpp:1160 >>>> artwork = NowPlayingInfoArtwork { sessionMetadata->artworkSrc(), sessionMetadata->artworkImage()->mimeType(), sessionMetadata->artworkImage()->data() }; >>> >>> Is there any reason to create the artwork if `sessionMetadata->artworkImage()->data()` is NULL? >> >> This is the point of the assert. An Image received here *must* have a SharedBuffer attached. It is an error if there's not. >> >> This is the core of the change. >> >> But Jer suggested I use a Ref rather than a RefPtr in NowPlayingInfoArtwork structure, however the code relies on the ability to set the value to a null pointer to indicate that the cached image should be used instead. So it would need to be made an Optional<Ref<SharedBuffer>> which is pretty much what a RefPtr is. > > Right. My point was that NowPlayingInfoArtwork without image data is useless, ASSERTing in a debug build is good but why create the NowPlayingInfoArtwork in a release build? And it won’t be. As artwork will not be set if the image as no data following this change.
Eric Carlson
Comment 10 2021-04-30 16:40:25 PDT
(In reply to Jean-Yves Avenard [:jya] from comment #9) > > Right. My point was that NowPlayingInfoArtwork without image data is useless, ASSERTing in a debug build is good but why create the NowPlayingInfoArtwork in a release build? > > And it won’t be. As artwork will not be set if the image as no data > following this change. Sorry, I am not being very clear. I was trying to say that there is no need to create the `Optional<NowPlayingInfoArtwork>` if we don't have image data, because that means we will also serialize and then deserialize it only to find out we can't use it.
Note You need to log in before you can comment on or make changes to this bug.