From 45cf599281840b1918821ce6d29253f0bc1a2844 Mon Sep 17 00:00:00 2001 From: WillyJL <49810075+WillyJL@users.noreply.github.com> Date: Sun, 22 Jun 2025 03:04:03 +0100 Subject: [PATCH] Sub-GHz: Fix freq analyzer deadlock by holding Ok Was more reproducible when using FM238 modulation, by stopping the worker thread in the input callback the system GUI thread was deadlocked when switching scenes if the timing was just right; this should be handled by app thread. --- CHANGELOG.md | 1 + .../scenes/subghz_scene_frequency_analyzer.c | 1 + .../main/subghz/views/subghz_frequency_analyzer.c | 15 ++++++--------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbac6f8ff..1f8fe4f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ - UL: Fix clipper date timestamp (by @luu176) - BadKB: Fix key combos main keys being case sensitive (by @WillyJL) - Sub-GHz: + - Fix freqquency analyzer deadlock when holding Ok (by @WillyJL) - UL: Fix CAME 24bit decoder (by @xMasterX) - UL: Tune holtek ht12x to decode holtek only and not conflict with came 12bit (by @xMasterX) - UL: Fix Rename scene bug, that was replacing file name with random name when Rename is opened then closed then opened again (by @xMasterX) diff --git a/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c b/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c index 9e5289c54..f490bdf7f 100644 --- a/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c +++ b/applications/main/subghz/scenes/subghz_scene_frequency_analyzer.c @@ -72,6 +72,7 @@ bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent e // Don't need to save, we already saved on short event (and on exit event too) subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE); scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneStart, 10); + scene_manager_previous_scene(subghz->scene_manager); // Stops the worker scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver); return true; } diff --git a/applications/main/subghz/views/subghz_frequency_analyzer.c b/applications/main/subghz/views/subghz_frequency_analyzer.c index b070d6f83..abbf511e3 100644 --- a/applications/main/subghz/views/subghz_frequency_analyzer.c +++ b/applications/main/subghz/views/subghz_frequency_analyzer.c @@ -255,9 +255,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { need_redraw = true; } } else if( - (event->type != InputTypeRelease && event->type != InputTypeRepeat) && + (event->type == InputTypeShort || event->type == InputTypeLong) && event->key == InputKeyOk) { - need_redraw = true; + need_redraw = false; bool updated = false; uint32_t frequency_to_save; with_view_model( @@ -286,22 +286,19 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { instance->worker, frequency_candidate); if(frequency_candidate > 0 && frequency_candidate != model->frequency_to_save) { model->frequency_to_save = frequency_candidate; + frequency_to_save = frequency_candidate; updated = true; } }, - true); + false); if(updated) { instance->callback(SubGhzCustomEventViewFreqAnalOkShort, instance->context); } - // First the device receives short, then when user release button we get long + // If it was a long press also send a second event if(event->type == InputTypeLong && frequency_to_save > 0) { - // Stop worker - if(subghz_frequency_analyzer_worker_is_running(instance->worker)) { - subghz_frequency_analyzer_worker_stop(instance->worker); - } - + // Worker stopped on app thread instead of GUI thread when switching scene in callback instance->callback(SubGhzCustomEventViewFreqAnalOkLong, instance->context); } }