CDMInstanceProxy: Use weak ptr for keeping player#900
Conversation
Use WeakPtr for keeping media player ptr as it can be used after player is destroyed. The media player can be removed by HTMLMediaElement::load() request while still waiting for decryption key. CDM is not aware of such case and tries to use m_player ptr anyway that resuts with crash. Also reset m_playbackBlockedWaitingForKey when calling load() as the player will be re-created.
|
I keep this on my radar, will need to upstream this. |
|
Hi @calvaris any update here? Is there anything needed from my side? |
|
Now that you ask, a use case would be nice. Regarding updates, I have a lot of work and other priorities. This is not just merging, it meens submitting upstream, studying it, etc. It is not just a shallow review, so I will do it as soon as I can. |
|
Sure, take your time The case here was that there was no key for decryption. Decryptor was waiting in tryWaitForKeyHandle() and this function was timeouted (after 7.0sec timeout). stoppedWaitingForKey() was scheduled to be called on main thread but decryptor recognized that there is no key and issued and error on pipeline and media element. JavaScript reloaded the player (vidoe.load()) that caused the new player to be created. Now the stoppedWaitingForKey was invoked on the main thread but the player is already gone. It was crashing sometimes if the memory was already overwritten but in most cases this was surprisingly working and the callback was even reaching HTMLMediaElement (that has new player already) |
https://bugs.webkit.org/show_bug.cgi?id=247977 Reviewed by Philippe Normand. Use WeakPtr for keeping media player ptr as it can be used after player is destroyed. The media player can be removed by HTMLMediaElement::load() request while still waiting for decryption key. CDM is not aware of such case and tries to use m_player ptr anyway that resuts with crash. Also reset m_playbackBlockedWaitingForKey when calling load() as the player will be re-created. Patch by Andrzej Surdej <Andrzej_Surdej@comcast.com> coming from WebPlatformForEmbedded/WPEWebKit#900. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::prepareForLoad): * Source/WebCore/platform/encryptedmedia/CDMProxy.h: (WebCore::CDMInstanceProxy::setPlayer): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached): Canonical link: https://commits.webkit.org/256823@main
https://bugs.webkit.org/show_bug.cgi?id=247977 Reviewed by Philippe Normand. Use WeakPtr for keeping media player ptr as it can be used after player is destroyed. The media player can be removed by HTMLMediaElement::load() request while still waiting for decryption key. CDM is not aware of such case and tries to use m_player ptr anyway that resuts with crash. Also reset m_playbackBlockedWaitingForKey when calling load() as the player will be re-created. Coming from #900. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::prepareForLoad): * Source/WebCore/platform/encryptedmedia/CDMProxy.h: (WebCore::CDMInstanceProxy::setPlayer): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached): Canonical link: https://commits.webkit.org/256823@main Signed-off-by: Xabier Rodriguez Calvar <calvaris@igalia.com>
|
Landed this PR as 683cfd9 on wpe-2.28. Closing. |
https://bugs.webkit.org/show_bug.cgi?id=247977 Reviewed by Philippe Normand. Use WeakPtr for keeping media player ptr as it can be used after player is destroyed. The media player can be removed by HTMLMediaElement::load() request while still waiting for decryption key. CDM is not aware of such case and tries to use m_player ptr anyway that resuts with crash. Also reset m_playbackBlockedWaitingForKey when calling load() as the player will be re-created. Patch by Andrzej Surdej <Andrzej_Surdej@comcast.com> coming from WebPlatformForEmbedded#900. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::prepareForLoad): * Source/WebCore/platform/encryptedmedia/CDMProxy.h: (WebCore::CDMInstanceProxy::setPlayer): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached): Canonical link: https://commits.webkit.org/256823@main
…gi?id=247977 [EME] CDMInstanceProxy: Use weak ptr for keeping player https://bugs.webkit.org/show_bug.cgi?id=247977 Reviewed by Philippe Normand. Use WeakPtr for keeping media player ptr as it can be used after player is destroyed. The media player can be removed by HTMLMediaElement::load() request while still waiting for decryption key. CDM is not aware of such case and tries to use m_player ptr anyway that resuts with crash. Also reset m_playbackBlockedWaitingForKey when calling load() as the player will be re-created. Patch by Andrzej Surdej <Andrzej_Surdej@comcast.com> coming from WebPlatformForEmbedded/WPEWebKit#900. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::prepareForLoad): * Source/WebCore/platform/encryptedmedia/CDMProxy.h: (WebCore::CDMInstanceProxy::setPlayer): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached): Canonical link: https://commits.webkit.org/256823@main
https://bugs.webkit.org/show_bug.cgi?id=247977 Reviewed by Philippe Normand. Use WeakPtr for keeping media player ptr as it can be used after player is destroyed. The media player can be removed by HTMLMediaElement::load() request while still waiting for decryption key. CDM is not aware of such case and tries to use m_player ptr anyway that resuts with crash. Also reset m_playbackBlockedWaitingForKey when calling load() as the player will be re-created. Patch by Andrzej Surdej <Andrzej_Surdej@comcast.com> coming from #900. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::prepareForLoad): * Source/WebCore/platform/encryptedmedia/CDMProxy.h: (WebCore::CDMInstanceProxy::setPlayer): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached): Canonical link: https://commits.webkit.org/256823@main
https://bugs.webkit.org/show_bug.cgi?id=247977 Reviewed by Philippe Normand. Use WeakPtr for keeping media player ptr as it can be used after player is destroyed. The media player can be removed by HTMLMediaElement::load() request while still waiting for decryption key. CDM is not aware of such case and tries to use m_player ptr anyway that resuts with crash. Also reset m_playbackBlockedWaitingForKey when calling load() as the player will be re-created. Patch by Andrzej Surdej <Andrzej_Surdej@comcast.com> coming from #900. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::prepareForLoad): * Source/WebCore/platform/encryptedmedia/CDMProxy.h: (WebCore::CDMInstanceProxy::setPlayer): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached): Canonical link: https://commits.webkit.org/256823@main
Use WeakPtr for keeping media player ptr as it can be used after
player is destroyed.
The media player can be removed by HTMLMediaElement::load() request
while still waiting for decryption key. CDM is not aware of such case
and tries to use m_player ptr anyway that resuts with crash.
Also reset m_playbackBlockedWaitingForKey when calling load()
as the player will be re-created.