Skip to content
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

Open
2 tasks done
Jacalz opened this issue Jan 11, 2025 · 1 comment
Open
2 tasks done

Investigate suspicious preference write delay #5393

Jacalz opened this issue Jan 11, 2025 · 1 comment
Labels
information-needed Further information is requested races Issues relating to race condition in Fyne

Comments

@Jacalz
Copy link
Member

Jacalz commented Jan 11, 2025

Checklist

  • I have searched the issue tracker for open issues that relate to the same feature, before opening a new one.
  • This issue only relates to a single feature. I will open new issues for any other features.

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

func (p *preferences) resetSavedRecently() {
go func() {
time.Sleep(time.Millisecond * 100) // writes are not always atomic. 10ms worked, 100 is safer.
p.prefLock.Lock()
p.savedRecently = false
changedDuringSaving := p.changedDuringSaving
p.changedDuringSaving = false
p.prefLock.Unlock()
if changedDuringSaving {
p.save()
}
}()
}

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?

@Jacalz Jacalz added information-needed Further information is requested races Issues relating to race condition in Fyne labels Jan 11, 2025
@Jacalz
Copy link
Member Author

Jacalz commented Jan 11, 2025

Original issue: #2449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
information-needed Further information is requested races Issues relating to race condition in Fyne
Projects
None yet
Development

No branches or pull requests

1 participant