-
Notifications
You must be signed in to change notification settings - Fork 568
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
Lifecycle issues on dynamic widget change #1258
Comments
This sounds like #1127? |
Yes, on quick skim it seems likely that's the same problem. It would be sweet if there's a patch for it. |
I found the branch and updated it, I'll have to fix some of out tests though because they do not even honor |
So after 4 to 5 hours of madness I believe I found the reason for this. First of, if I am correct, this is purely a Crochet issue and not really Druid's fault. What I believe causes this, is that Crochet's Lines 704 to 719 in ecd0a24
you can see, that is uses an inner_ctx for the child. Because we don't do this children_changed never becomes true for any widgets other than the root, which means that this part of WidgetPod::lifecycle always gets skipped:Lines 736 to 751 in ecd0a24
And thus WidgetAdded never gets propagated anywhere but to the root.
So far I have no idea how we could do this correctly, because we have no way of constructing such a "child context" from Crochet. |
Thanks, this is a very useful analysis, and not what I was expecting. I haven't thought about it too deeply yet, but it seems like the right path forward might be to add a method to Druid to create an appropriate child context. |
Closed by #1352 and raphlinus/crochet#19 🎉 |
This is a crash when using master Druid with the Crochet prototype. The lifecycle problems were happening before, but only giving warnings. Now text layout is highly dependent on getting lifecycle right. Though it's observed in Crochet, I'm pretty sure it's a problem in Druid, and will probably bite us any time we're trying to reconfigure children dynamically.
The following println-debugging trace should give a clue what's going wrong. It's from a simplified version of the "counter" example, stripped down to just be a label. I can post a gist of the example, and a diff adding the println, if it'd be useful.
The "children changed" log is when the child widget (a label) gets added to the (modified) flex container; it's this line in particular.
The underlying problem seems pretty simple: it's doing the WidgetAdded lifecycle after the layout, which seems pretty clearly wrong to me. I think this problem may be hidden in other examples because there might be an intervening
update
or something, but I also wouldn't be surprised if it were possible to trigger in extant code even outside Crochet.I haven't investigated the lifecycle ordering logic carefully yet. It feels like a bit of a haunted graveyard. But I am willing to dig in.
(PS: yes, the × symbol is mojibake. Because it's 2020 and all software is broken)
The text was updated successfully, but these errors were encountered: