holochain / launcher-tauri

Desktop launcher to install and use Holochain apps locally
261 stars 21 forks source link

Infinite install app spinner #182

Closed matthme closed 1 year ago

matthme commented 1 year ago

Installing an app sporadically gets stuck at the "Installing App..." spinner.

It looks like this Mutex cannot be ever acquired in that case due to a deadlock.

matthme commented 1 year ago

Explanation: Additionally to pubkey_map_state: tauri::State<'_, Arc<Mutex<HashMap<String, AgentPubKey>>>>, tauri::State<'_, LauncherState> is also used by both tauri commands sign_zome_call and install_app. So when install_app acquired the lock on tauri::State<'_, LauncherState> while sign_zome_call was holding the lock on pubkey_map_state: tauri::State<'_, Arc<Mutex<HashMap<String, AgentPubKey>>>> but before it acquired the lock on tauri::State<'_, LauncherState> itself, a deadlock occured and install_app could not acquire the lock on pubkey_map_state: tauri::State<'_, Arc<Mutex<HashMap<String, AgentPubKey>>>> because sign_zome_call never dropped it.

Solved by acquiring the pub_key_map lock in a dedicated scope.