Make children life update in BDL-load #1542
Merged
Conversation
This changes two things: 1) We generally derive CompositeDrawable and add hierarchies in load(), this will cause those children to now potentially turn alive if they need to be. Previously only children added during non-bdl-load would turn alive during bdl-load. 2) Similar to (1), drawables added during derived bdl-loads that should be alive will now get loaded.
Updated flow chart. Raw for future reference: |
Simplified diagram on the wiki: https://github.com/ppy/osu-framework/wiki/Diagram:-Loading-of-a-drawable |
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.
The issue that sparked this: ppy/osu#2496
Explanation:
DrawableMedal
binds tomedalContainer.OnLoadComplete
, to set the position of some text contained within that container (i.e.unlocked.Position = new Vector2(0f, medalContainer.DrawSize.Y / 2 + 10);
).This is expecting two things:
medalContainer
are loaded.medalContainer
is alive.(1) Is fulfilled by
LoadComplete
being called fromUpdateSubTree
, which occurs post-all-children-being-loaded.(2) Is where the issue occurs.
CompositeDrawable.load()
calledUpdateChildrenLife
, but it would get blocked by load state check incheckChildLife
: https://github.com/ppy/osu-framework/compare/master...smoogipoo:async-child-life?expand=1#diff-2f079688019880634dc5249946a02502L407.The next time child life gets updated is post-LoadComplete. So the children of
medalContainer
were loaded, but not alive.This results in autosize not finding alive children and giving a
DrawSize
of 0.A similar change as proposed in this PR was submitted some ~6 months ago (#1072) but then reverted (#1083). The reasoning was that some elements were broken (https://streamable.com/6pwqf, ppy/osu#1366). Although these elements are not broken with the same changes as in the original PR, I chose to go down a different route and maintain that "children are not alive or loaded before their parent is loaded".
There are a few significant changes here:
checkChildLife
no longer does load state checking. This is now done inUpdateChildrenLife
andAddInternal
- the only other use-case ofcheckChildLife
through publicly-acccessible methods.UpdateChildrenLife
has been moved to a new private methodcheckChildrenLife
. The new method, likecheckChildLife
, does not perform load state checking.checkChildLife
, bypassing the load state checking ofUpdateChildrenLife
.Additionally, I think the following will result in some discussion:
I've moved the call to check children life to
LoadAsyncComplete
, which happens after BDL-load,but still on the asynchronous context, and prior to the drawable being given a
Ready
load state.This was done because the alive state of children defined in BDL-load would previously be computed on the Update thread, when UpdateChildrenLife would be normally invoked.
Testing
It's hard to define exactly what to test with this. Obviously I've tested that it fixes the issue that sparked this, but I've also gone through all visual tests (osu! and framework-side) and found nothing breaking.