After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 736936 - Use GResources for theme loading
Use GResources for theme loading
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2014-09-19 02:27 UTC by Cosimo Cecchi
Modified: 2014-10-15 01:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
background: use GFiles instead of filenames (11.32 KB, patch)
2014-09-19 02:27 UTC, Cosimo Cecchi
reviewed Details | Review
texture-cache: remove unused base64 code path (2.68 KB, patch)
2014-09-19 02:28 UTC, Cosimo Cecchi
committed Details | Review
st: always use GFile internally (43.04 KB, patch)
2014-09-19 02:28 UTC, Cosimo Cecchi
reviewed Details | Review
background: port to new GFile MetaBackground API (12.46 KB, patch)
2014-09-19 02:28 UTC, Cosimo Cecchi
reviewed Details | Review
theme: convert stylesheet loading to GFile (16.72 KB, patch)
2014-09-19 02:28 UTC, Cosimo Cecchi
reviewed Details | Review
theme: make a GResource (9.78 KB, patch)
2014-09-19 02:28 UTC, Cosimo Cecchi
reviewed Details | Review
background: use GFiles instead of filenames (11.26 KB, patch)
2014-09-19 04:23 UTC, Cosimo Cecchi
committed Details | Review
st: always use GFile internally (43.92 KB, patch)
2014-09-19 04:24 UTC, Cosimo Cecchi
none Details | Review
background: port to new GFile MetaBackground API (12.46 KB, patch)
2014-09-19 04:24 UTC, Cosimo Cecchi
committed Details | Review
theme: convert stylesheet loading to GFile (17.65 KB, patch)
2014-09-19 04:24 UTC, Cosimo Cecchi
none Details | Review
theme: make a GResource (8.83 KB, patch)
2014-09-19 04:24 UTC, Cosimo Cecchi
committed Details | Review
st: always use GFile internally (45.12 KB, patch)
2014-09-19 04:40 UTC, Cosimo Cecchi
none Details | Review
theme: convert stylesheet loading to GFile (19.98 KB, patch)
2014-09-19 04:40 UTC, Cosimo Cecchi
committed Details | Review
st: always use GFile internally (45.07 KB, patch)
2014-09-19 17:13 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2014-09-19 02:27:41 UTC
Currently, the Shell theme uses files in $pkgdatadir. Move these to a GResource will make startup and loading faster.
Comment 1 Cosimo Cecchi 2014-09-19 02:27:44 UTC
Created attachment 286543 [details] [review]
background: use GFiles instead of filenames

We want to use GResources for system backgrounds, so move this to a
GFile.
Comment 2 Cosimo Cecchi 2014-09-19 02:28:17 UTC
Created attachment 286544 [details] [review]
texture-cache: remove unused base64 code path

This was introduced in b0c6cf3f to support image data for web search
providers, which do not exist anymore. Just remove it.
Comment 3 Cosimo Cecchi 2014-09-19 02:28:20 UTC
Created attachment 286545 [details] [review]
st: always use GFile internally

We're moving the theme infrastructure towards GResource, so as a first
step move all the loading to use GFiles instead of URIs or paths.
Comment 4 Cosimo Cecchi 2014-09-19 02:28:24 UTC
Created attachment 286546 [details] [review]
background: port to new GFile MetaBackground API
Comment 5 Cosimo Cecchi 2014-09-19 02:28:28 UTC
Created attachment 286547 [details] [review]
theme: convert stylesheet loading to GFile

In preparation to making it a GResource.
Comment 6 Cosimo Cecchi 2014-09-19 02:28:32 UTC
Created attachment 286548 [details] [review]
theme: make a GResource

Now that we have all the infrastructure ready, port the theme to a
GResource.
Comment 7 Jasper St. Pierre (not reading bugmail) 2014-09-19 02:43:24 UTC
Review of attachment 286544 [details] [review]:

I swore I removed this at some point, or at least tried to. Perhaps this is needed for the message tray? I'm fine with removing it after the freeze and seeing what turns up.
Comment 8 Jasper St. Pierre (not reading bugmail) 2014-09-19 02:44:26 UTC
Review of attachment 286546 [details] [review]:

I assume you need to file mutter patches for this?

::: js/ui/background.js
@@ +128,3 @@
+function _fileEqual0(file1, file2) {
+    if (!file1 && !file2)
+        return true;

I'd write this as:

if (file1 == file2)
    return true;
Comment 9 Jasper St. Pierre (not reading bugmail) 2014-09-19 02:46:19 UTC
Review of attachment 286547 [details] [review]:

Technically, you should update tests/testcommon/ui.js, but I'd be surprised if those tests still run anyway.

::: src/st/st-theme.c
@@ +103,3 @@
+             GFile *file2)
+{
+  if ((file1 == NULL) && (file2 == NULL))

Again:

  if (file1 == file2)
    return TRUE;
Comment 10 Jasper St. Pierre (not reading bugmail) 2014-09-19 02:48:24 UTC
Review of attachment 286543 [details] [review]:

Oh, sorry, I missed this mutter patch.

I didn't realize we were going to move GResources to a system background. I assume it's for noise-texture.png?

::: src/compositor/meta-background-image.c
@@ +135,3 @@
+
+  pixbuf = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (stream), NULL,
+                                       &error);

Same line, please.

::: src/compositor/meta-background.c
@@ +246,3 @@
+             GFile *file2)
+{
+  if ((file1 == NULL) && (file2 == NULL))

Yikes, I keep finding this code all over the place. You know what to do :)
Comment 11 Jasper St. Pierre (not reading bugmail) 2014-09-19 02:52:38 UTC
Review of attachment 286545 [details] [review]:

::: src/st/st-texture-cache.c
@@ +1181,1 @@
   key = g_strconcat (CACHE_PREFIX_URI, uri, NULL);

I wonder if we should use g_file_hash instead.

::: src/st/st-theme-node.c
@@ +3852,3 @@
+  if ((node->background_image != NULL) &&
+      (other->background_image != NULL) &&
+      !g_file_equal (node->background_image, other->background_image))

Not gonna go for another file_equal0? :)
Comment 12 Jasper St. Pierre (not reading bugmail) 2014-09-19 02:52:38 UTC
Review of attachment 286545 [details] [review]:

::: src/st/st-texture-cache.c
@@ +1181,1 @@
   key = g_strconcat (CACHE_PREFIX_URI, uri, NULL);

I wonder if we should use g_file_hash instead.

::: src/st/st-theme-node.c
@@ +3852,3 @@
+  if ((node->background_image != NULL) &&
+      (other->background_image != NULL) &&
+      !g_file_equal (node->background_image, other->background_image))

Not gonna go for another file_equal0? :)
Comment 13 Jasper St. Pierre (not reading bugmail) 2014-09-19 02:54:51 UTC
Review of attachment 286548 [details] [review]:

Is there any reason not to put it in the same resource as all the others? So we just have a gnome-shell.gresource instead of a -js and a -theme one?

Also, I assume you double-checked that the CSS file and assets are actually being loaded from the resource and not the disk? I noticed you didn't actually touch _st_theme_resolve_uri, so you should probably triple-check that one.

::: js/ui/extensionSystem.js
@@ +119,3 @@
         if (stylesheetFile.query_exists(null)) {
             let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
+            theme.load_stylesheet(stylesheetFile);

I feel like this should be in an earlier patch...
Comment 14 Cosimo Cecchi 2014-09-19 04:23:35 UTC
Created attachment 286552 [details] [review]
background: use GFiles instead of filenames

We want to use GResources for system backgrounds, so move this to a
GFile.
Comment 15 Cosimo Cecchi 2014-09-19 04:24:20 UTC
Created attachment 286553 [details] [review]
st: always use GFile internally

We're moving the theme infrastructure towards GResource, so as a first
step move all the loading to use GFiles instead of URIs or paths.
Comment 16 Cosimo Cecchi 2014-09-19 04:24:24 UTC
Created attachment 286554 [details] [review]
background: port to new GFile MetaBackground API
Comment 17 Cosimo Cecchi 2014-09-19 04:24:28 UTC
Created attachment 286555 [details] [review]
theme: convert stylesheet loading to GFile

In preparation to making it a GResource.
Comment 18 Cosimo Cecchi 2014-09-19 04:24:32 UTC
Created attachment 286556 [details] [review]
theme: make a GResource

Now that we have all the infrastructure ready, port the theme to a
GResource.
Comment 19 Cosimo Cecchi 2014-09-19 04:40:30 UTC
Created attachment 286559 [details] [review]
st: always use GFile internally

We're moving the theme infrastructure towards GResource, so as a first
step move all the loading to use GFiles instead of URIs or paths.
Comment 20 Cosimo Cecchi 2014-09-19 04:40:58 UTC
Created attachment 286561 [details] [review]
theme: convert stylesheet loading to GFile

In preparation to making it a GResource.
Comment 21 Cosimo Cecchi 2014-09-19 04:44:03 UTC
Thanks for the reviews Jasper.

I think I addressed all of your points, except for a couple:
- I don't believe the data: stuff is used by the message tray. At least if it does, it's totally non-obvious... should be fine to remove for now.
- the background stuff was moved to GFile exactly for noise-texture.png
- I did not make these a single GResource because it would be hard to build. If you look at how we make the JS GResource, some files are actually generated at build time, and then not included in the dist, which would be harder to do across two different directories. If you strongly feel for this, I can work on it, otherwise I think it could be punted to a future improvement
- new patchset also fixes tests
Comment 22 Jasper St. Pierre (not reading bugmail) 2014-09-19 05:49:32 UTC
Review of attachment 286552 [details] [review]:

OK.
Comment 23 Jasper St. Pierre (not reading bugmail) 2014-09-19 05:51:34 UTC
Review of attachment 286561 [details] [review]:

Looks good.
Comment 24 Jasper St. Pierre (not reading bugmail) 2014-09-19 05:52:14 UTC
Review of attachment 286554 [details] [review]:

OK.
Comment 25 Jasper St. Pierre (not reading bugmail) 2014-09-19 05:53:08 UTC
Review of attachment 286556 [details] [review]:

Yep.
Comment 26 Cosimo Cecchi 2014-09-19 17:13:35 UTC
Created attachment 286652 [details] [review]
st: always use GFile internally

--

Minor change to the test
Comment 27 Jasper St. Pierre (not reading bugmail) 2014-09-19 17:34:36 UTC
Review of attachment 286652 [details] [review]:

Oh, yep, nice catch.
Comment 28 Owen Taylor 2014-09-19 18:09:39 UTC
(In reply to comment #0)
> Currently, the Shell theme uses files in $pkgdatadir. Move these to a GResource
> will make startup and loading faster.

Curious - do you have any data for this?
Comment 29 Jasper St. Pierre (not reading bugmail) 2014-09-19 18:18:46 UTC
Our computer uses a spinning disk, and moving JS files to a resource cut a good 3-4 seconds off of startup time. We're hoping the same will happen with themes and theme assets.
Comment 30 Owen Taylor 2014-09-19 19:23:22 UTC
(In reply to comment #29)
> Our computer uses a spinning disk, and moving JS files to a resource cut a good
> 3-4 seconds off of startup time. We're hoping the same will happen with themes
> and theme assets.

Shell currrently has 133 JS files - assuming pessimistically 1 seek per file, 15ms each seek, that would be 2.0sec. It's pretty grim if things are twice as bad as my "pessimistic" estimates. This would imply that you have some serious fragmentation or layout issues. Since you aren't going to get away from having to read a lot of files on startup it's certainly something you mght want to a investigate at some point - look at a directory of files from a single package - where are the blocks for those files physically on disk?

(ostree is possibly problematical here since it will replace subsets of files in a directory and not touch others ... even on a SSD there seem to be considerable gradual-slowdown effects showing up on perf.gnome.org. Though actual users won't be doing thousands of ostree pulls.)

This isn't to say that even if you gain just a few fractions of a second from this (36 files in the GNOME upstream theme) it's a bad idea - just that 3-4 sec number makes me go "hmmmm".
Comment 31 Jasper St. Pierre (not reading bugmail) 2014-10-15 01:56:12 UTC
Comment on attachment 286552 [details] [review]
background: use GFiles instead of filenames

Attachment 286552 [details] pushed as a37f632 - background: use GFiles instead of filenames
Comment 32 Jasper St. Pierre (not reading bugmail) 2014-10-15 01:56:29 UTC
Attachment 286544 [details] pushed as 2dc41c9 - texture-cache: remove unused base64 code path
Attachment 286554 [details] pushed as 38add2e - background: port to new GFile MetaBackground API
Attachment 286556 [details] pushed as 49c4ba5 - theme: make a GResource
Attachment 286561 [details] pushed as 642bf2b - theme: convert stylesheet loading to GFile
Attachment 286652 [details] pushed as 328bb1c - st: always use GFile internally