Skip to content

Commit 836a110

Browse files
authored
Fix broken animations by removing deadlock (#2993)
* Fix animations not working by removing deadlock * Remove log
1 parent 4b11dce commit 836a110

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ target/
33
*.exrc
44
perf.data*
55
profile.json
6+
profile.json.gz
67
flamegraph.svg
78
.idea/
89
.direnv

frontend/wasm/src/editor_api.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl EditorHandle {
239239
wasm_bindgen_futures::spawn_local(poll_node_graph_evaluation());
240240

241241
if !EDITOR_HAS_CRASHED.load(Ordering::SeqCst) {
242-
editor_and_handle(|_, handle| {
242+
handle(|handle| {
243243
handle.dispatch(InputPreprocessorMessage::CurrentTime {
244244
timestamp: js_sys::Date::now() as u64,
245245
});
@@ -914,27 +914,37 @@ fn set_timeout(f: &Closure<dyn FnMut()>, delay: Duration) {
914914
fn editor<T: Default>(callback: impl FnOnce(&mut editor::application::Editor) -> T) -> T {
915915
EDITOR.with(|editor| {
916916
let mut guard = editor.try_lock();
917-
let Ok(Some(editor)) = guard.as_deref_mut() else { return T::default() };
917+
let Ok(Some(editor)) = guard.as_deref_mut() else {
918+
log::error!("Failed to borrow editor");
919+
return T::default();
920+
};
918921

919922
callback(editor)
920923
})
921924
}
922925

923926
/// Provides access to the `Editor` and its `EditorHandle` by calling the given closure with them as arguments.
924927
pub(crate) fn editor_and_handle(callback: impl FnOnce(&mut Editor, &mut EditorHandle)) {
925-
EDITOR_HANDLE.with(|editor_handle| {
928+
handle(|editor_handle| {
926929
editor(|editor| {
927-
let mut guard = editor_handle.try_lock();
928-
let Ok(Some(editor_handle)) = guard.as_deref_mut() else {
929-
log::error!("Failed to borrow editor handle");
930-
return;
931-
};
932-
933930
// Call the closure with the editor and its handle
934931
callback(editor, editor_handle);
935932
})
936933
});
937934
}
935+
/// Provides access to the `EditorHandle` by calling the given closure with them as arguments.
936+
pub(crate) fn handle(callback: impl FnOnce(&mut EditorHandle)) {
937+
EDITOR_HANDLE.with(|editor_handle| {
938+
let mut guard = editor_handle.try_lock();
939+
let Ok(Some(editor_handle)) = guard.as_deref_mut() else {
940+
log::error!("Failed to borrow editor handle");
941+
return;
942+
};
943+
944+
// Call the closure with the editor and its handle
945+
callback(editor_handle);
946+
});
947+
}
938948

939949
async fn poll_node_graph_evaluation() {
940950
// Process no further messages after a crash to avoid spamming the console

0 commit comments

Comments
 (0)