Mojiificaiton of the audio output device: calling the mojo callback the after moving to other thread

59 views
Skip to first unread message

Riadh Chtara

unread,
Apr 4, 2016, 1:00:12 PM4/4/16
to chromium-mojo
Hello,

We are trying to replace AudioHostMsg_CreateStream and AudioMsg_NotifyStreamCreated ipc message with mojo.
The flow of that is currently the  following:
  • After AudioHostMsg_CreateStream is received,  AudioRendererHost::OnCreateStream is called on the io thread.
  • OnCreateStream triggers after many calls the creation of media::AudioOutputController via media::AudioOutputController::Create
  • media::AudioOutputController::Create we move to the  controller->message_loop_ thread and call  AudioOutputController::DoCreate
  • AudioOutputController::DoCreate calls AudioRendererHost::AudioEntry::OnCreated.
  • to return the results,  AudioRendererHost::AudioEntry::OnCreated move to the io thread and calls AudioRendererHost::DoCompleteCreation
  •  AudioMsg_NotifyStreamCreated ipc message is called from AudioRendererHost::DoCompleteCreation to return the values
In our new mojified Implementation we want to replace both the tow calls with a simple mojo call
   CreateStream(
        int32 stream_id_,
        int32 render_frame_id_,
        AudioOutputStreamParameters params) =>
        (handle<shared_buffer> shared_buffer,
         handle socket_descriptor,
         AudioOutputStream stream);

As you already know, we need to use a callback: const AudioOutput::CreateStreamCallback for doing so.

Our Mojo service is in the io thread. 
Calling AudioOutputClient::CreateStream from the renderer is going to trigger the call   of  AudioOutputImpl::CreateStream (io thread)  which triggers something similar the previous flow (we just added the callback to the functions arguments, so we can transfer it until we reach  AudioRendererHost::DoCompleteCreationMojo where the callback is called in the io thread: During this transfer we move from the io thread to controller->message_loop_and then we come back the io thread.

However, we have an issue with the callback and chrome crash when the callback is constructed.
There is check that failed : Check failed: thread_checker_.CalledOnValidThread().  in relation with the callback which is  weird as the call back is run in the io thread.
If we  call the callback at   AudioOutputController::Create before moving from the io thread to the 
controller->message_loop_, it works.

If we store the callback somewhere in an attribute  before moving from the io thread to the controller->message_loop_  and used the attribute in AudioRendererHost::DoCompleteCreationMojo, it works too (however we can do that for concurrency issues.


Code source  (CL)

Could you please help us solve this issues?


Thanks a lot
Riadh



Error log:

[22638:22638:0404/132058:WARNING:message_queue.cc(38)] Leaking 2 ports in unreceived messages
[1:1:0404/132058:ERROR:render_thread_impl.cc(702)] Start MOJO
[1:1:0404/132058:ERROR:render_thread_impl.cc(702)] Start MOJO
[22691:22691:0404/132059:WARNING:ipc_message_attachment_set.cc(57)] MessageAttachmentSet destroyed with unconsumed descriptors: 0/1
[1:1:0404/132103:ERROR:render_thread_impl.cc(702)] Start MOJO
[1:1:0404/132107:ERROR:render_thread_impl.cc(702)] Start MOJO
[22638:22674:0404/132107:WARNING:audio_output_impl.cc(98)] error
[22638:22674:0404/132108:WARNING:extension_protocols.cc(430)] Failed to GetPathForExtension: pkedcjkdefgpdelpbcmbmeomcjbeemfm
[22638:22674:0404/132108:WARNING:url_request_job_manager.cc(89)] Failed to map: chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/cast_sender.js
[22638:22674:0404/132110:WARNING:extension_protocols.cc(430)] Failed to GetPathForExtension: fjhoaacokmgbjemoflkofnenfaiekifl
[22638:22674:0404/132110:WARNING:url_request_job_manager.cc(89)] Failed to map: chrome-extension://fjhoaacokmgbjemoflkofnenfaiekifl/cast_sender.js
[22638:22674:0404/132111:WARNING:extension_protocols.cc(430)] Failed to GetPathForExtension: boadgeojelhgndaghljhdicfkmllpafd
[22638:22674:0404/132111:WARNING:url_request_job_manager.cc(89)] Failed to map: chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js
[22638:22674:0404/132112:WARNING:extension_protocols.cc(430)] Failed to GetPathForExtension: dliochdbjfkdbacpmhlcpmleaejidimm
[22638:22674:0404/132112:WARNING:url_request_job_manager.cc(89)] Failed to map: chrome-extension://dliochdbjfkdbacpmhlcpmleaejidimm/cast_sender.js
[22638:22674:0404/132113:WARNING:extension_protocols.cc(430)] Failed to GetPathForExtension: enhhojjnijigcajfphajepfemndkmdlo
[22638:22674:0404/132113:WARNING:url_request_job_manager.cc(89)] Failed to map: chrome-extension://enhhojjnijigcajfphajepfemndkmdlo/cast_sender.js
[22638:22674:0404/132113:WARNING:extension_protocols.cc(430)] Failed to GetPathForExtension: fmfcbgogabcbclcofgocippekhfcmgfj
[22638:22674:0404/132113:WARNING:url_request_job_manager.cc(89)] Failed to map: chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/cast_sender.js
[22638:22674:0404/132116:WARNING:audio_output_impl.cc(98)] error
[1:15:0404/132117:ERROR:ffmpeg_audio_decoder.cc(364)] Could not initialize audio decoder: 86077
[1:2:0404/132117:ERROR:audio_message_filter.cc(111)] test CreateStream 1
[1:2:0404/132117:ERROR:audio_message_filter.cc(115)] test CreateStream 1
[22638:22674:0404/132117:WARNING:audio_output_impl.cc(58)] set-1414812757set-1414812757
[22638:22677:0404/132117:FATAL:shared_data.h(84)] Check failed: thread_checker_.CalledOnValidThread(). 
#0 0x7fe06242f1de base::debug::StackTrace::StackTrace()
#1 0x7fe06246d65f logging::LogMessage::~LogMessage()
#2 0x7fe057585542 mojo::internal::SharedData<>::Holder::Retain()
#3 0x7fe05a7f60b7 mojo::internal::SharedData<>::SharedData()
#4 0x7fe05a7f606d mojo::internal::SharedPtr<>::SharedPtr()
#5 0x7fe05a7f603d mojo::Callback<>::Callback()
#6 0x7fe05a7f600d std::_Head_base<>::_Head_base()
#7 0x7fe05a7f5fe8 _ZNSt11_Tuple_implILm2EJN4mojo8CallbackIFviNS0_16ScopedHandleBaseINS0_18SharedBufferHandleEEENS2_INS0_6HandleEEENS0_12InterfacePtrIN7content17AudioOutputStreamEEEEEEEEC2ERKSC_
#8 0x7fe05b5224b3 _ZNSt11_Tuple_implILm1EJiN4mojo8CallbackIFviNS0_16ScopedHandleBaseINS0_18SharedBufferHandleEEENS2_INS0_6HandleEEENS0_12InterfacePtrIN7content17AudioOutputStreamEEEEEEEEC2ERKiRKSC_
#9 0x7fe05b52244d _ZNSt11_Tuple_implILm0EJ13scoped_refptrIN7content17AudioRendererHostEEiN4mojo8CallbackIFviNS4_16ScopedHandleBaseINS4_18SharedBufferHandleEEENS6_INS4_6HandleEEENS4_12InterfacePtrINS1_17AudioOutputStreamEEEEEEEEC2IRKPS2_JRKiRKSF_EEEOT_DpOT0_
#10 0x7fe05b522377 _ZNSt5tupleIJ13scoped_refptrIN7content17AudioRendererHostEEiN4mojo8CallbackIFviNS4_16ScopedHandleBaseINS4_18SharedBufferHandleEEENS6_INS4_6HandleEEENS4_12InterfacePtrINS1_17AudioOutputStreamEEEEEEEEC2IJRKPS2_RKiRKSF_EvEEDpOT_
#11 0x7fe05b52227f _ZN4base8internal9BindStateINS0_15RunnableAdapterIMN7content17AudioRendererHostEFviRKN4mojo8CallbackIFviNS5_16ScopedHandleBaseINS5_18SharedBufferHandleEEENS7_INS5_6HandleEEENS5_12InterfacePtrINS3_17AudioOutputStreamEEEEEEEEEFvPS4_iSI_EJRKSM_RKiSI_EEC2IJSP_SR_SI_EEERKSL_DpOT_
#12 0x7fe05b51cfcb _ZN4base4BindIMN7content17AudioRendererHostEFviRKN4mojo8CallbackIFviNS3_16ScopedHandleBaseINS3_18SharedBufferHandleEEENS5_INS3_6HandleEEENS3_12InterfacePtrINS1_17AudioOutputStreamEEEEEEEJRKPS2_RKiSG_EEENS_8CallbackINS_8internal22MakeUnboundRunTypeImplIT_JDpT0_EE4TypeELNSP_8CopyModeE1EEESR_DpOSS_
#13 0x7fe05b516780 content::AudioRendererHost::AudioEntry::OnCreated()
#14 0x7fe05a7f1b0e media::AudioOutputController::DoCreateMojo()
#15 0x7fe057b371ac _ZN4base8internal15RunnableAdapterIMN26PepperFlashSettingsManager4CoreEFvbRKN3IPC13ChannelHandleEEE3RunIJbS7_EEEvPS3_DpOT_
#16 0x7fe057b37106 _ZN4base8internal12InvokeHelperILb0EvNS0_15RunnableAdapterIMN26PepperFlashSettingsManager4CoreEFvbRKN3IPC13ChannelHandleEEEEE8MakeItSoIJPS4_bS8_EEEvSB_DpOT_
#17 0x7fe05a7f619d _ZN4base8internal7InvokerINS_13IndexSequenceIJLm0ELm1ELm2EEEENS0_9BindStateINS0_15RunnableAdapterIMN5media21AudioOutputControllerEFvbRKN4mojo8CallbackIFviNS8_16ScopedHandleBaseINS8_18SharedBufferHandleEEENSA_INS8_6HandleEEENS8_12InterfacePtrIN7content17AudioOutputStreamEEEEEEEEEFvPS7_bSM_EJR13scoped_refptrIS7_EbSM_EEENS0_12InvokeHelperILb0EvSP_EEFvvEE3RunEPNS0_13BindStateBaseE
#18 0x7fe0572d136e base::Callback<>::Run()
#19 0x7fe0624321be base::debug::TaskAnnotator::RunTask()
#20 0x7fe06248317f base::MessageLoop::RunTask()
#21 0x7fe062483408 base::MessageLoop::DeferOrRunPendingTask()
#22 0x7fe0624835d2 base::MessageLoop::DoWork()
#23 0x7fe06248f733 base::MessagePumpDefault::Run()
#24 0x7fe062482baf base::MessageLoop::RunHandler()
#25 0x7fe0624f5f94 base::RunLoop::Run()
#26 0x7fe062481c54 base::MessageLoop::Run()
#27 0x7fe062557599 base::Thread::Run()
#28 0x7fe0625578e9 base::Thread::ThreadMain()
#29 0x7fe0625462aa base::(anonymous namespace)::ThreadFunc()
#30 0x7fe051a05182 start_thread
#31 0x7fe04e58847d clone

Aborted (core dumped)
rchtara@rchtara:~/chromium/src/out/Default$ 





Anand Mistry

unread,
Apr 4, 2016, 6:19:04 PM4/4/16
to chromium-mojo
That stack trace doesn't make any sense. mojo::Callback doesn't use mojo::internal::SharedPtr any more since I changed it a couple of weeks back. When was the last time you synced?

Riadh Chtara

unread,
Apr 5, 2016, 12:17:05 PM4/5/16
to Anand Mistry, chromium-mojo
I synced today and that problem has disappeared.
Thanks a  lot for youur help
Riadh


--
You received this message because you are subscribed to the Google Groups "chromium-mojo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-moj...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-mojo/4eac7344-765d-4cc5-84b8-d2d4c8c16814%40chromium.org.

Reply all
Reply to author
Forward
0 new messages