fix(windows): marshal EventSink calls to platform thread#1961
fix(windows): marshal EventSink calls to platform thread#1961OlehHumeniuk wants to merge 2 commits into
Conversation
|
|
||
| #include "audio_player.h" | ||
| #include "audioplayers_helpers.h" | ||
| #include "platform_thread_handler.h" // NEW: Include platform thread handler |
There was a problem hiding this comment.
While we love documentation, adding a comment to each inserted line doesn't really help us and just generates noise. Could you remove the comments where not necessary?
|
Thank you for the contribution. I will need some time to get this reviewed, as I am not a C(++) expert. But I will be happy to move forward with this platform topic. |
|
I had a quick look, the approach looks good. I still need to evaluate the thread logic, though. |
|
I tried this approach, but didn't get it working within 2 hours. I would prefer that we spent the time in
Leave it open as inspiration and reminder to tackle this in flutter for now. |
Description
Fixes threading issue where MediaFoundation callbacks were calling Flutter's EventSink from MTA (Multi-Threaded Apartment) threads instead of the platform thread.
Problem
This causes UI freezes and potential crashes during audio loading on Windows.
Root Cause
MediaEngine's
IMFMediaEngineNotify::EventNotify()is called on MTA threads, but Flutter requires all Platform Channel messages to be sent from the platform thread.Solution
PlatformThreadHandlerclass that creates a hidden message-only windowPostMessage/SendMessage) to marshal callbacks to platform threadEventStreamHandlerto automatically dispatch calls through the handlerChanges
platform_thread_handler.hevent_stream_handler.haudioplayers_windows_plugin.cppCMakeLists.txtTesting
Notes
audio_player.cpp- fix is transparent