File tree Expand file tree Collapse file tree 3 files changed +6
-2
lines changed
Expand file tree Collapse file tree 3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change 11/// This is a hack to get around the fact that wry is currently not thread safe on android
22///
33/// We want to acquire this mutex before doing anything with the virtualdom directly
4+ #[ cfg( target_os = "android" ) ]
45pub fn android_runtime_lock ( ) -> std:: sync:: MutexGuard < ' static , ( ) > {
56 use std:: sync:: { Mutex , OnceLock } ;
67
Original file line number Diff line number Diff line change @@ -330,9 +330,9 @@ impl App {
330330 {
331331 // This is a place where wry says it's threadsafe but it's actually not.
332332 // If we're patching the app, we want to make sure it's not going to progress in the interim.
333- let lock = crate :: android_sync_lock:: android_runtime_lock ( ) ;
333+ #[ cfg( target_os = "android" ) ]
334+ let _lock = crate :: android_sync_lock:: android_runtime_lock ( ) ;
334335 dioxus_devtools:: apply_changes ( & webview. dom , & hr_msg) ;
335- drop ( lock) ;
336336 }
337337
338338 webview. poll_vdom ( ) ;
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ impl WebviewEdits {
7878 let response = match serde_json:: from_slice ( & data_from_header) {
7979 Ok ( event) => {
8080 // we need to wait for the mutex lock to let us munge the main thread..
81+ #[ cfg( target_os = "android" ) ]
8182 let _lock = crate :: android_sync_lock:: android_runtime_lock ( ) ;
8283 self . handle_html_event ( event)
8384 }
@@ -557,6 +558,7 @@ impl WebviewInstance {
557558
558559 {
559560 // lock the hack-ed in lock sync wry has some thread-safety issues with event handlers and async tasks
561+ #[ cfg( target_os = "android" ) ]
560562 let _lock = crate :: android_sync_lock:: android_runtime_lock ( ) ;
561563 let fut = self . dom . wait_for_work ( ) ;
562564 pin_mut ! ( fut) ;
@@ -568,6 +570,7 @@ impl WebviewInstance {
568570 }
569571
570572 // lock the hack-ed in lock sync wry has some thread-safety issues with event handlers
573+ #[ cfg( target_os = "android" ) ]
571574 let _lock = crate :: android_sync_lock:: android_runtime_lock ( ) ;
572575
573576 self . edits
You can’t perform that action at this time.
0 commit comments