Skip to content

Background Panel: Don't stall the main loop

Christian Hergert requested to merge wip/chergert/threaded-background-loading into main

This fixes #3167 (closed)

Ambitiously setting the Milestone for GNOME 47 but I understand if maintainers want to push back on that.

Commit 1

We want to coalesce all updates that happen within a main loop cycle into a single update. And we want to defer that update until after the current frame has been drawn.

Additionally, since we may have interstitial states where there is no texture loaded, handle that gracefully and do nothing when the paintable snapshots.

Commit 2

Just some cleanup to make it more clear what happens in the next. We have unused API externally, so drop it.

Commit 3

This is really the crux of things.

We don't want to mutate existing GnomeBG on a thread because it would invalidate the internal cache state. However, we can create all new GnomeBG instances on a thread and then take ownership of them on the main thread.

So start by making the API async to get a GdkPixbuf for the CcBackgroundItem. Create a new GnomeBG and set the properties on that but do the actual pixbuf loading on a thread.

Then keep a sequence number so we can detect of two operations were in flight at the same time and only the newer request updates the cached thumbnail state.

Some effort was used to validate the correctness with -Db_sanitize=address (ASAN) in both gnome-control-center and libgnome-desktop.

Merge request reports