GNOME Bugzilla – Bug 632818
style-changed not always emitted when widget is first styled
Last modified: 2021-07-05 14:14:12 UTC
Applying the attached patch shows that the appwell icongrid gets allocated without emitting style-changed, which is bad for code that assumes it can read CSS values at style-changed time, and then use those cached values for size request/allocation.
Created attachment 172952 [details] demonstrate the bug
The patch in https://bugzilla.gnome.org/show_bug.cgi?id=627083#c9 makes that *never* the case (for a big performance win) and has a set of fixes for at least some of the problems.
Comment on attachment 172952 [details] demonstrate the bug Not a real patch
Comment on attachment 172952 [details] demonstrate the bug (clear patch flag)
A little more detail here about emission of ::style-changed - not sure if it's the same issue or not - but things are particularly troublesome if we request the size of an unmapped widget. We have two separate states in StWidget: priv->theme_node == NULL widget->priv->is_style_dirty = TRUE If you have an unmapped widget with a dirty style, then calling st_widget_get_theme_node() on it causes priv->theme_node to be set, but: ::style-changed is not emitted widget->priv->is_style_dirty is left TRUE When the widget is mapped, then we emit ::style-changed at that point and clear the is_style_dirty flag. This may actually be about as good as we can do, but it causes some bugs. In particular, for StIcon, if you get call clutter_actor_get_preferred_size() on an unmapped widget, the icon_size field which is computed in style_changed is not updated so we don't request the correct size.
Created attachment 184817 [details] [review] StIcon: force icon_size to be updated before computing size Here's a workaround for StIcon. Not immediately needed (was easier to just map stuff first), but attaching it here for future reference. === ::style-changed isn't normally emitted for unmapped widgets; calling st_widget_ensure_style() forces this so that priv->icon_size is correct before we compute the size.
Comment on attachment 184817 [details] [review] StIcon: force icon_size to be updated before computing size Well... I'm glad you have a simpler patch in bug 645949, because I don't like this one. :-) A better version of the same idea might be to call ensure_style() from st_widget_queue_relayout()? That would also fix the original IconGrid bug. It definitely seems weird that sometimes we update priv->theme_node without emitting style-changed.
Is this still an issue?
(In reply to comment #8) > Is this still an issue? no idea. (un-NEEDINFO-ing to (a) get it off my bugzilla user info page, and (b) get it back into queries where someone who knows the answer might actually end up seeing at it)
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/ Thank you for your understanding and your help.