Repository navigation
Conversation
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
…e bottom (EdgeTX#7967) Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…sh (EdgeTX#7980) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eTX#7976) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
WasmSimulatorInterface::stop() holds m_mutex across simuStop(), which joins the firmware threads. Those threads read analog inputs through host_simuGetAnalog -> getAnalogValue(), which also took m_mutex. If a firmware thread read an analog after stop() took the lock, the join never returned. The GUI thread then blocked on the same mutex in isRunning(), so the 2s stop timeout never fired and Companion hung. This shows up when the simulator is closed while the firmware is still booting, because edgeTxInit() reads analogs (throttle/switch checks, splash inactivity check) before the menus task can exit. Store the analog values as atomics so getAnalogValue() and setAnalogValue() no longer need m_mutex. Also close the SDL audio device after simuStop() rather than before, so the firmware audio task cannot be inside SDL_QueueAudio() while the device is closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closing the simulator while the firmware is still booting can hang Companion. This fixes a deadlock in
WasmSimulatorInterfacebetweenstop()and the firmware threads.Cause
stop()holdsm_mutexacrosssimuStop(), which joins the firmware threads.host_simuGetAnalog→getAnalogValue(), which also lockedm_mutex. A thread that reads an analog afterstop()takes the lock blocks forever, so the join never returns.simulator->isRunning()inSimulatorWidget::stop(), which takes the same mutex. It blocks there, so the 2s stop timeout never fires and Companion hangs.It only happens when closing early because the menus task has to finish
edgeTxInit()before it can exit, and that reads analogs (throttle/switch checks, splash inactivity check). In steady state the threads exit without another analog read.Changes
m_analogValuesasstd::atomic<int16_t>, sogetAnalogValue()andsetAnalogValue()no longer takem_mutex.simuStop()rather than before, so the firmware audio task cannot be insideSDL_QueueAudio()while the device is closed.Testing
std::atomic<int16_t>[]member initialiser compiles with-std=c++17.🤖 Generated with Claude Code