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.
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.
This guard is fine and all to address the direct failure, but what are the guarantees the component will function correctly after hitting it? By which I mean: say that the waveform regeneration is requested, but the track isn't loaded yet. This early-guard will prevent the crash, but what is going to ensure that the waveform gets regenerated at some later point?
There is this code in
Update()
:osu/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs
Lines 168 to 178 in 0f7093c
but the guarantees it gives come with a lot of caveats (component needs to be not hovered, not locked, and even then
showFromBeat()
/showFromTime()
have early-return guards that prevent possibly-redundant regenerations from happening etc.)I'd probably see this as a flow based around
Cached
or something. Everything that forces the display regeneration would instead invalidate theCached
, andUpdate()
would check if theCached
is invalid and if it's not, run this method.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.
Now that I think about it, this issue has actually been a thing for a while as far as I can tell. I've had cases the display doesn't update until I start to play the track (likely because it hit the case in this PR or something very similar but not as fatal).
Was hoping for a quick fix, but will look at doing this more correctly.
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.
I've used
Scheduler.AddOnce
as it feels like a pretty simple solution here.