RESOLVED FIXED 167165
[GStreamer] Clear out m_appsinkCaps in AppendPipeline::appsinkCapsChanged() before using outPtr()
https://bugs.webkit.org/show_bug.cgi?id=167165
Summary [GStreamer] Clear out m_appsinkCaps in AppendPipeline::appsinkCapsChanged() b...
Zan Dobersek
Reported 2017-01-18 10:42:59 PST
[GStreamer] Clear out m_appsinkCaps in AppendPipeline::appsinkCapsChanged() before using outPtr()
Attachments
Patch (1.73 KB, patch)
2017-01-18 10:46 PST, Zan Dobersek
no flags
Patch (2.45 KB, patch)
2017-01-19 02:19 PST, Zan Dobersek
no flags
Patch (2.03 KB, patch)
2017-01-20 07:20 PST, Zan Dobersek
no flags
Archive of layout-test-results from ews115 for mac-elcapitan (1.62 MB, application/zip)
2017-01-20 08:41 PST, Build Bot
no flags
Zan Dobersek
Comment 1 2017-01-18 10:46:08 PST
Enrique Ocaña
Comment 2 2017-01-18 12:00:56 PST
Comment on attachment 299157 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=299157&action=review > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:605 > + m_appsinkCaps = nullptr; I'm not sure that's the proper way to fix the bug. Have a look at how was the original code[1] before the migration to GRefPtr() and to the behaviour of gst_caps_replace()[2]. The function is thought to replace one pointer by another, automatically onreffing the old caps and reffing the new ones. Maybe the right fix would be to use raw pointers again? [1] https://github.com/eocanha/webkit/blob/mse-backport-rebased-20160414/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp#L1652 [2] https://developer.gnome.org/gstreamer/1.0/gstreamer-GstCaps.html#gst-caps-replace
Zan Dobersek
Comment 3 2017-01-19 00:41:13 PST
Comment on attachment 299157 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=299157&action=review >> Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:605 >> + m_appsinkCaps = nullptr; > > I'm not sure that's the proper way to fix the bug. Have a look at how was the original code[1] before the migration to GRefPtr() and to the behaviour of gst_caps_replace()[2]. The function is thought to replace one pointer by another, automatically onreffing the old caps and reffing the new ones. Maybe the right fix would be to use raw pointers again? > > [1] https://github.com/eocanha/webkit/blob/mse-backport-rebased-20160414/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp#L1652 > [2] https://developer.gnome.org/gstreamer/1.0/gstreamer-GstCaps.html#gst-caps-replace It's not a bug, this works around the assert in GRefPtr<>::outPtr(). IMO the assert is valid, but this specific usage of it isn't. Using raw pointers doesn't fix anything, it disables a much more simpler control of an object.
Zan Dobersek
Comment 4 2017-01-19 00:47:00 PST
(In reply to comment #3) > It's not a bug, this works around the assert in GRefPtr<>::outPtr(). IMO the > assert is valid, but this specific usage of it isn't. > ... but this specific usage of GRefPtr<>::outPtr() isn't.*
Carlos Garcia Campos
Comment 5 2017-01-19 00:54:15 PST
Comment on attachment 299157 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=299157&action=review >>> Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:605 >>> + m_appsinkCaps = nullptr; >> >> I'm not sure that's the proper way to fix the bug. Have a look at how was the original code[1] before the migration to GRefPtr() and to the behaviour of gst_caps_replace()[2]. The function is thought to replace one pointer by another, automatically onreffing the old caps and reffing the new ones. Maybe the right fix would be to use raw pointers again? >> >> [1] https://github.com/eocanha/webkit/blob/mse-backport-rebased-20160414/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp#L1652 >> [2] https://developer.gnome.org/gstreamer/1.0/gstreamer-GstCaps.html#gst-caps-replace > > It's not a bug, this works around the assert in GRefPtr<>::outPtr(). IMO the assert is valid, but this specific usage of it isn't. > > Using raw pointers doesn't fix anything, it disables a much more simpler control of an object. I think this at least deserves a comment, explaining that gst_caps_replace does the unref. However, maybe we should do what we did for GUniqueOutPtr and replace the assert with a clear(). That way this is done automatically here and everywhere else and we avoid similar problems in the future.
Xabier Rodríguez Calvar
Comment 6 2017-01-19 01:02:54 PST
Comment on attachment 299157 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=299157&action=review >>>> Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:605 >>>> + m_appsinkCaps = nullptr; >>> >>> I'm not sure that's the proper way to fix the bug. Have a look at how was the original code[1] before the migration to GRefPtr() and to the behaviour of gst_caps_replace()[2]. The function is thought to replace one pointer by another, automatically onreffing the old caps and reffing the new ones. Maybe the right fix would be to use raw pointers again? >>> >>> [1] https://github.com/eocanha/webkit/blob/mse-backport-rebased-20160414/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp#L1652 >>> [2] https://developer.gnome.org/gstreamer/1.0/gstreamer-GstCaps.html#gst-caps-replace >> >> It's not a bug, this works around the assert in GRefPtr<>::outPtr(). IMO the assert is valid, but this specific usage of it isn't. >> >> Using raw pointers doesn't fix anything, it disables a much more simpler control of an object. > > I think this at least deserves a comment, explaining that gst_caps_replace does the unref. However, maybe we should do what we did for GUniqueOutPtr and replace the assert with a clear(). That way this is done automatically here and everywhere else and we avoid similar problems in the future. I agree with Carlos here. Let's bring consistency between GRefPtr and GUniquePtr.
Zan Dobersek
Comment 7 2017-01-19 02:02:41 PST
(In reply to comment #2) > Comment on attachment 299157 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=299157&action=review > > > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:605 > > + m_appsinkCaps = nullptr; > > I'm not sure that's the proper way to fix the bug. Have a look at how was > the original code[1] before the migration to GRefPtr() and to the behaviour > of gst_caps_replace()[2]. The function is thought to replace one pointer by > another, automatically onreffing the old caps and reffing the new ones. > Maybe the right fix would be to use raw pointers again? > > [1] > https://github.com/eocanha/webkit/blob/mse-backport-rebased-20160414/Source/ > WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp#L1652 > [2] > https://developer.gnome.org/gstreamer/1.0/gstreamer-GstCaps.html#gst-caps- > replace OK, let's try raw pointers again in order to keep the atomic replacement.
Zan Dobersek
Comment 8 2017-01-19 02:19:15 PST
Carlos Garcia Campos
Comment 9 2017-01-19 05:23:25 PST
*** Bug 167199 has been marked as a duplicate of this bug. ***
Xabier Rodríguez Calvar
Comment 10 2017-01-19 06:47:02 PST
Comment on attachment 299241 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=299241&action=review > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:611 > if (m_playerPrivate && previousCapsWereNull) if (m_playerPrivate && !currentCaps) And remove the variable declaration from above
Xabier Rodríguez Calvar
Comment 11 2017-01-19 06:59:43 PST
Comment on attachment 299241 [details] Patch Please write a comment on the code because it looks like we are doing things more complicated than what they are for no reason.
Xabier Rodríguez Calvar
Comment 12 2017-01-19 07:09:23 PST
Enrique, do you recall why gst_caps_replace is needed here?
Zan Dobersek
Comment 13 2017-01-19 08:31:44 PST
Comment on attachment 299241 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=299241&action=review >> Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:611 >> if (m_playerPrivate && previousCapsWereNull) > > if (m_playerPrivate && !currentCaps) > > And remove the variable declaration from above That's not correct -- if the gst_caps_replace() call succeeded, then currentCaps will now hold the same pointer as the caps GRefPtr<>.
Enrique Ocaña
Comment 14 2017-01-19 10:53:09 PST
(In reply to comment #12) > Enrique, do you recall why gst_caps_replace is needed here? At the moment (using raw pointers) it was the best way to automate the operation of unreffing the old caps and reffing the new ones. Now that I think about it, the smart pointer behaviour already do the job of gst_caps_replace(), so we could just do something like this: GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(m_appsink.get(), "sink")); GRefPtr<GstCaps> newCaps = adoptGRef(gst_pad_get_current_caps(pad.get())); GRefPtr<GstCaps> currentCaps = m_appsinkCaps; if (!newCaps) return; // This means that we're right after a new track has appeared. Otherwise, it's a caps change inside the same track. bool previousCapsWereNull = !m_appsinkCaps; m_appsinkCaps = newCaps; if (currentCaps != newCaps) { if (m_playerPrivate && previousCapsWereNull) m_playerPrivate->trackDetected(this, m_oldTrack, m_track); didReceiveInitializationSegment(); gst_element_set_state(m_pipeline.get(), GST_STATE_PLAYING); }
Xabier Rodríguez Calvar
Comment 15 2017-01-20 00:38:00 PST
(In reply to comment #13) > That's not correct -- if the gst_caps_replace() call succeeded, then > currentCaps will now hold the same pointer as the caps GRefPtr<>. Indeed, how could I miss that?
Xabier Rodríguez Calvar
Comment 16 2017-01-20 00:40:52 PST
(In reply to comment #14) > Now that I think about it, the smart pointer behaviour already do the job of > gst_caps_replace(), so we could just do something like this: This would be my preference.
Zan Dobersek
Comment 17 2017-01-20 07:20:52 PST
Build Bot
Comment 18 2017-01-20 08:41:48 PST
Comment on attachment 299347 [details] Patch Attachment 299347 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/2920646 New failing tests: media/modern-media-controls/media-controller/media-controller-auto-hide-mouse-leave-after-play.html
Build Bot
Comment 19 2017-01-20 08:41:52 PST
Created attachment 299349 [details] Archive of layout-test-results from ews115 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews115 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Zan Dobersek
Comment 20 2017-01-22 00:30:45 PST
Comment on attachment 299347 [details] Patch Clearing flags on attachment: 299347 Committed r211026: <http://trac.webkit.org/changeset/211026>
Zan Dobersek
Comment 21 2017-01-22 00:30:54 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.