File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
vnext/Microsoft.ReactNative Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -75,17 +75,24 @@ void CoalescingEventEmitter::EnsureRenderCallbackRegistered() noexcept {
75
75
}
76
76
77
77
void CoalescingEventEmitter::OnRendering () noexcept {
78
- std::unique_lock lock (m_mutex );
78
+ auto jsDispatcher = m_context-> Properties (). Get ( ReactDispatcherHelper::JSDispatcherProperty ()). as <IReactDispatcher>( );
79
79
80
80
// Submit the batch of requests to the JS queue
81
- while (!m_eventQueue. empty ()) {
82
- auto &evt = m_eventQueue. front ();
83
- if (!evt. expired ) {
84
- m_context-> CallJSFunction ( " RCTEventEmitter " , " receiveEvent " , std::move (evt. args )) ;
81
+ jsDispatcher. Post ([weakThis{ get_weak ()}]() noexcept {
82
+ auto strongThis = weakThis. get ();
83
+ if (!strongThis ) {
84
+ return ;
85
85
}
86
86
87
- m_eventQueue.pop_front ();
88
- }
87
+ while (!strongThis->m_eventQueue .empty ()) {
88
+ auto &evt = strongThis->m_eventQueue .front ();
89
+ if (!evt.expired ) {
90
+ strongThis->m_context ->CallJSFunction (" RCTEventEmitter" , " receiveEvent" , std::move (evt.args ));
91
+ }
92
+
93
+ strongThis->m_eventQueue .pop_front ();
94
+ }
95
+ });
89
96
90
97
// Don't leave the callback continuously registered as it can waste power.
91
98
// See https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.compositiontarget.rendering?view=winrt-19041
You can’t perform that action at this time.
0 commit comments