Fix: Resolve DataStore IOException by checking single instance before Koin (#2044)#2091
Merged
Merged
Conversation
v1.2.1: Hot fix for changing new backend
v1.3.0: New version
This was referenced Jun 1, 2026
Author
|
Hi Max,
I’m sorry to hear it crashed on your machine, but I assure you I thoroughly
tested this branch locally on my setup before submitting, and it ran
perfectly without any exceptions.
Since your follow-up commit fixed the issue by wrapping restoreRequest in
an AtomicReference, it looks like this was a thread-safety/concurrency
issue. As you know, those can sometimes pass locally but behave differently
depending on the specific hardware, OS, or thread timing of the machine
running it. I appreciate you catching that and pushing the thread-safety
fix to stabilize it.
Just to reassure you, I have also fully compiled and tested my other open
PRs on my physical devices (Save Queue #2095 and the 120Hz unlock #2098)
and they are both working flawlessly on my end.
Let me know if there is anything specific you want me to double-check on
those so we can ensure they are completely safe to merge across all
environments.
…On Wed, Jun 3, 2026 at 12:35 PM Nguyễn Đức Tuấn Minh < ***@***.***> wrote:
*maxrave-dev* left a comment (maxrave-dev/SimpMusic#2091)
<#2091 (comment)>
Shit, I forget test your code before merge, then crassh app now, your code
are AI generated without testing, shit
—
Reply to this email directly, view it on GitHub
<#2091?email_source=notifications&email_token=BIYBWEKEVSAPWK24T4QCSS3457ILZA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINRRGAYDSNBYG442M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4610094879>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BIYBWEO4NL7QJGJRKXODHPT457ILZAVCNFSM6AAAAACZUQBVIOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DMMJQGA4TIOBXHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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.
Fixes #2044
(Note to maintainer: Apologies for the messy Git history on the previous PR. I've closed that one and opened this clean branch pointing to dev with exactly one commit.)
Description of the Bug:
When a user launches a second instance of the SimpMusic Desktop app while the first instance is still running, the app crashes with a fatal java.io.IOException (Unable to rename ... settings.preferences_pb.tmp). This is caused by a file-locking collision on Windows because multiple instances of AndroidX DataStore attempt to access the same preferences file.
Root Cause:
In DesktopApp.kt, startKoin { ... } was being executed before the application checked if it was a single instance (SingleInstanceManager.isSingleInstance). Because Koin initialized the dependency graph immediately, the newly spawned Java process created a duplicate DataStore object. This duplicate DataStore attempted to lock and modify settings.preferences_pb while the original process still held the lock.
Resolution:
Moved the SingleInstanceManager.isSingleInstance() check to the very beginning of the runDesktopApp function, entirely before startKoin is called.
Added a restoreRequest callback to ensure the window state is correctly brought back to the foreground when a duplicate launch is intercepted.
Now, if a second instance is launched, it immediately passes the request and deep links to the running instance and gracefully exits before it ever attempts to initialize Koin or touch the DataStore preferences file on disk.