Bug 1833207 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

`DMABufDevice::LoadFormatModifiers()` requires to be called on [main thread](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/widget/gtk/DMABufLibWrapper.cpp#302) , which implicitly implies [`FFmpegVideoDecoder::Init()`](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#462) needs to be run on main thread as well since `DMABufDevice::LoadFormatModifiers()` will be called via the following path:
1. FFmpegVideoDecoder::Init()
2. FFmpegVideoDecoder::InitVAAPIDecoder() //  MOZ_WAYLAND_USE_VAAPI
3. FFmpegVideoDecoder::CreateVAAPIDeviceContext()
4. widget::GetDMABufDevice()
5. widget::DMABufDevice::Configure()
6. widget::DMABufDevice::LoadFormatModifiers()

However, `FFmpegVideoDecoder::Init()` can be called on non-main thread in some cases. For example, in WebCodecs, media decoder is going to be exposed to both main thread and worker thread. This means either MediaDataDecoder can be exposed to main thread and worker thread, or MediaDataDecoder is working in a dedicated task queue (non-main thread) that is operated by main thread and worker thread.
`DMABufDevice::LoadFormatModifiers()` requires to be called on [main thread](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/widget/gtk/DMABufLibWrapper.cpp#302) , which implicitly implies [`FFmpegVideoDecoder::Init()`](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#462) needs to be run on the main thread as well since `DMABufDevice::LoadFormatModifiers()` will be called via the following path:
1. FFmpegVideoDecoder::Init()
2. FFmpegVideoDecoder::InitVAAPIDecoder() //  MOZ_WAYLAND_USE_VAAPI
3. FFmpegVideoDecoder::CreateVAAPIDeviceContext()
4. widget::GetDMABufDevice()
5. widget::DMABufDevice::Configure()
6. widget::DMABufDevice::LoadFormatModifiers()

However, `FFmpegVideoDecoder::Init()` can be called on non-main thread in some cases. For example, in WebCodecs, media decoder is going to be exposed to both main thread and worker thread. This means either MediaDataDecoder work on main thread and worker thread, or MediaDataDecoder is working in a dedicated task queue (non-main thread) that is operated by main thread and worker thread, depending on the implementation of VideoDecoder and AudioDecoder interfaces.
`DMABufDevice::LoadFormatModifiers()` requires to be called on [main thread](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/widget/gtk/DMABufLibWrapper.cpp#302) , which implicitly implies [`FFmpegVideoDecoder::Init()`](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#462) needs to be run on the main thread as well since `DMABufDevice::LoadFormatModifiers()` will be called via the following path:
1. FFmpegVideoDecoder::Init()
2. FFmpegVideoDecoder::InitVAAPIDecoder() //  MOZ_WAYLAND_USE_VAAPI
3. FFmpegVideoDecoder::CreateVAAPIDeviceContext()
4. widget::GetDMABufDevice()
5. widget::DMABufDevice::Configure()
6. widget::DMABufDevice::LoadFormatModifiers()

However, `FFmpegVideoDecoder::Init()` can be called on non-main thread in some cases. For example, in WebCodecs, media decoder is going to be exposed to both main thread and worker thread. This means either MediaDataDecoder work on main thread and worker thread, or MediaDataDecoder is working in a dedicated task queue (non-main thread) that is operated by main thread and worker thread, depending on the implementation of [VideoDecoder](https://w3c.github.io/webcodecs/#videodecoder-interface) interface.
`DMABufDevice::LoadFormatModifiers()` requires to be called on [main thread](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/widget/gtk/DMABufLibWrapper.cpp#302) , which implicitly implies [`FFmpegVideoDecoder::Init()`](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#462) needs to be run on the main thread as well since `DMABufDevice::LoadFormatModifiers()` will be called via the following path:
1. FFmpegVideoDecoder::Init()
2. FFmpegVideoDecoder::InitVAAPIDecoder() //  MOZ_WAYLAND_USE_VAAPI
3. FFmpegVideoDecoder::CreateVAAPIDeviceContext()
4. widget::GetDMABufDevice()
5. widget::DMABufDevice::Configure()
6. widget::DMABufDevice::LoadFormatModifiers()

However, `FFmpegVideoDecoder::Init()` can be called on non-main thread in some cases. For example, in WebCodecs, media decoder is going to be exposed to both main thread and worker thread. This means either MediaDataDecoder works on main thread and worker thread, or MediaDataDecoder is working in a dedicated task queue (non-main thread) that is operated by main thread and worker thread, depending on the implementation of [VideoDecoder](https://w3c.github.io/webcodecs/#videodecoder-interface) interface.
`DMABufDevice::LoadFormatModifiers()` requires to be called on [main thread](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/widget/gtk/DMABufLibWrapper.cpp#302) , which implicitly implies [`FFmpegVideoDecoder::Init()`](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#462) needs to be run on the main thread as well since `DMABufDevice::LoadFormatModifiers()` will be called via the following path:
1. FFmpegVideoDecoder::Init()
2. FFmpegVideoDecoder::InitVAAPIDecoder() //  MOZ_WAYLAND_USE_VAAPI
3. FFmpegVideoDecoder::CreateVAAPIDeviceContext()
4. widget::GetDMABufDevice()
5. widget::DMABufDevice::Configure()
6. widget::DMABufDevice::LoadFormatModifiers()

However, `FFmpegVideoDecoder::Init()` can be called on a non-main thread in some cases. For example, in WebCodecs, the media decoder is going to be exposed to both the main thread and the worker thread. This means either MediaDataDecoder works on the main thread or worker thread, or MediaDataDecoder is working in a dedicated task queue (non-main thread) that is operated by the main thread and worker thread, depending on the implementation of [VideoDecoder](https://w3c.github.io/webcodecs/#videodecoder-interface) interface.
`DMABufDevice::LoadFormatModifiers()` requires to be called on [main thread](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/widget/gtk/DMABufLibWrapper.cpp#302) , which implicitly implies [`FFmpegVideoDecoder::Init()`](https://searchfox.org/mozilla-central/rev/656beaee18f39790b81daf3014b15875ca125160/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#462) needs to be run on the main thread as well since `DMABufDevice::LoadFormatModifiers()` will be called via the following path:
1. FFmpegVideoDecoder::Init()
2. FFmpegVideoDecoder::InitVAAPIDecoder() //  MOZ_WAYLAND_USE_VAAPI
3. FFmpegVideoDecoder::CreateVAAPIDeviceContext()
4. widget::GetDMABufDevice()
5. widget::DMABufDevice::Configure()
6. widget::DMABufDevice::LoadFormatModifiers()

However, `FFmpegVideoDecoder::Init()` can be called on a non-main thread in some cases. For example, in WebCodecs, the media decoder is going to be exposed to both the main thread and the worker thread. This means either MediaDataDecoder works on the main thread or worker thread, or MediaDataDecoder works in a dedicated task queue (off-main thread) that is operated by the main thread and worker thread, depending on the implementation of [VideoDecoder](https://w3c.github.io/webcodecs/#videodecoder-interface) interface.

Back to Bug 1833207 Comment 0