Skip to content

Commit b4a3c73

Browse files
committed
Temp fixes for MediaStream
1 parent 9322360 commit b4a3c73

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Plugins/NativeCamera/Source/MediaDevices.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ namespace Babylon::Plugins::Internal
3838
}
3939
}
4040

41-
auto runtimeScheduler{std::make_unique<JsRuntimeScheduler>(JsRuntime::GetFromJavaScript(env))};
42-
MediaStream::NewAsync(env, videoConstraints).then(runtimeScheduler->Get(), arcana::cancellation::none(), [runtimeScheduler = std::move(runtimeScheduler), env, deferred](const arcana::expected<Napi::Object, std::exception_ptr>& result) {
41+
MediaStream::NewAsync(env, videoConstraints).then(arcana::inline_scheduler, arcana::cancellation::none(), [env, deferred](const arcana::expected<Napi::Object, std::exception_ptr>& result) {
4342
if (result.has_error())
4443
{
4544
deferred.Reject(Napi::Error::New(env, result.error()).Value());

Plugins/NativeCamera/Source/MediaStream.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,17 @@ namespace Babylon::Plugins
5858

5959
MediaStream::~MediaStream()
6060
{
61-
if (m_cameraDevice != nullptr)
62-
{
63-
// The cameraDevice should be destroyed on the JS thread as it may need to access main thread resources
64-
// move ownership of the cameraDevice to a lambda and dispatch it with the runtimeScheduler so the destructor
65-
// is called from that thread.
66-
m_runtimeScheduler.Get()([cameraDevice = std::move(m_cameraDevice)]() {});
67-
}
61+
// TODO: Is this still necessary?
62+
// if (m_cameraDevice != nullptr)
63+
// {
64+
// // The cameraDevice should be destroyed on the JS thread as it may need to access main thread resources
65+
// // move ownership of the cameraDevice to a lambda and dispatch it with the runtimeScheduler so the destructor
66+
// // is called from that thread.
67+
// m_runtimeScheduler.Get()([cameraDevice = std::move(m_cameraDevice)]() {});
68+
// }
69+
70+
// Wait for async operations to complete.
71+
m_runtimeScheduler.Rundown();
6872
}
6973

7074
Napi::Value MediaStream::GetVideoTracks(const Napi::CallbackInfo& info)

0 commit comments

Comments
 (0)