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
Make start animations idempotent and improve runner performance #4451
base: develop
Are you sure you want to change the base?
Conversation
Hmm, all the tests seem to be timing out. Deadlock? Maybe some unit test assumption was broken because the animations in fyne_demo work fine. |
Yes it could be. There are assumptions in the Unit Test regarding threading and timing. Fixing them is a good thing if you can figure out where they are ;). I could try to take a look over the coming days if it would help. |
Yes, I think that would be helpful. I am pretty confident my actual code changes haven't introduced the possibility of deadlock. And I gave up, at least for now, trying to track down the assumptions in the test that may need updating. |
Confirmed - container package tests time out locally as well (linux and Darwin). Investigating. |
tabs.go:441 calls |
Aha, I updated it it to this and that seemed to work. I hope this helps: // Start registers the animation with the application run-loop and starts its execution.
func (a *Animation) Start() {
a.mutex.Lock()
if a.state == AnimationStateRunning {
return
}
a.state = AnimationStateRunning
a.mutex.Unlock()
d := CurrentApp().Driver().(interface{ StartAnimationInternal(*Animation) })
d.StartAnimationInternal(a)
} |
animation.go
Outdated
// | ||
// Since: 2.5 | ||
func (a *Animation) State() AnimationState { | ||
return a.state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not use the mutex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to atomic so we're good here
With the change proposed above, it seems like it would be a good fit to use old := a.state.Swap(AnimationStateRunning)
if old == AnimationStateRunning {
return
} |
OK I think there is still a possible timing issue where an animation could end up running twice if it is stopped and then immediately started again. I wonder if it's possible to move the runner to the public animation package but make it non-exported? It's hard to get communication right between the animation instance and the runner. |
Description:
Fixes #(issue)
Checklist:
Where applicable: