-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate suspicious preference write delay #5393
Comments
Original issue: #2449 |
I have looked into it and I think it needs to remain. If you remove this delay then the file write happens, watcher kicks, data is re-read, change is notes, write happens etc etc. |
Ah, okay. What I'm thinking about then is if we perhaps can call the write on the same thread and instead have some kind of way to keep track of when the last write happened, like we do for cleaning the canvas? |
I'm not sure I am following. For a period of time we need to ignore callbacks, and reset after that time. I have a small fix that can remove the need to track if preferences are loading because that is now synchronous - but I believe the timer is still required. |
Alright. I'm not sure I quite know what I'm talking about. I just find the problem interesting and want to have a look at it :) |
That PR does seem very sensible. I'm sure there are more things that we can tidy up that code now that it is synchronous. That is what I'm interested in looking at. For some reason, I kind of find refactoring and cleanup more interesting to implement than new APIs :) |
I'll leave the rest to you because fundamentally I cannot see a way to have a delay in here because of the change -> write -> notify -> read -> change loop I mentioned above. |
Yeah, I'm sure you're right. Just want to have a look :) |
Checklist
Is your feature request related to a problem?
Noted in one of the race fixes PRs, this sleep looks suspicious. Sleeping to avoid race conditions is almost always a hacky solution around what really is lack of synchronization. We should look at if this sleep is correct.
fyne/app/preferences.go
Lines 50 to 63 in 4a875d9
Is it possible to construct a solution with the existing API?
Yes
Describe the solution you'd like to see.
We need to find out how these writes are happening and in what way operations need to be synchronized. Perhaps running them on the same thread does not cause any problems? Maybe we just need some kind of locking inbetween?
The text was updated successfully, but these errors were encountered: