Consider more efficient list-based stylesheet processing

Bug #883879 reported by Cris Dywan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Midori Web Browser
Fix Released
Undecided
Unassigned

Bug Description

The new shared global stylesheet API used internally is based on concatenating strings. There's an alternative approach in an older patch based on lists. It should be straight-forward to replace it and find out if it's faster.

See https://launchpadlibrarian.net/83464903/websettings-and-addons.patch

Cris Dywan (kalikiana)
description: updated
Revision history for this message
gue5t gue5t (gue5t) wrote :

I'm currently working on this, but I think the list-based implementation depended too heavily on integer ids as indices to be adapted exactly as suggested. I'm putting together a solution based on storing both styles and their lengths (as GStrings) in the hashtable. That way we get the time benefits when we generate the final uri, don't have to maintain parallel data structures, and don't need any auxiliary indices.

Revision history for this message
gue5t gue5t (gue5t) wrote :

A note: styles seem broken as of <http://git.xfce.org/apps/midori/commit/?id=ea15198b343b5359b3e13ee196a277c121e95d1d>... can anyone reproduce this? It appears that we're not shadowing the property correctly, and webkit ends up reading MidoriWebSettings::user-stylesheet-uri when it asks for user-stylesheet-uri.

Revision history for this message
gue5t gue5t (gue5t) wrote :

Attached is a patch that fixes the shadowing of the property (writes to user-stylesheet-uri wrap the value, reads get the value webkit should read; this seems to be the only way for this to work properly) and implements a more efficient hash-based method of generating strings that only base64s individual chunks upon their addition. It also moves the "import" to the beginning of the generated CSS because this is required for import rules to apply.

This approach does not do anything with lists, but that still might be worthwhile to determine if it's faster or not.

Cris Dywan (kalikiana)
Changed in midori:
status: New → In Progress
Revision history for this message
Cris Dywan (kalikiana) wrote :

The patch ends up saving a bogus user-stylesheet-uri, which is some base64 value generated before. I updated the patch to save cached/ encoded user-stylesheet-uri separately from the original and use object data to save the original in main.c (plus lots of stylistic fixes). For some reason WebKit crashes frequently, although in principle it does work, it may just be the hour of the night that I don't see the problem. The special-case feels more ugly than it should be, though I'd also dislike to rename the setting that appears in the file.

Revision history for this message
gue5t gue5t (gue5t) wrote :

Currently adblock is generating its style rule incorrectly (lacking the terminating "{display: none !important}" clause), and main.c's settings_save_to_file is setting a string gkeyfile key to NULL if user-stylesheet-uri is unset in the original config file. This patch fixes these two bugs.

Revision history for this message
Alexander Butenko (avb) wrote :

i agree regarding adblock, my bad. No idea how it still was working, plus we need to remove extra string in adblock js code. Attaching code.

Revision history for this message
Cris Dywan (kalikiana) wrote :

I committed the Adblock fix and the final version of the faster Base64 work separately, it is now working smoothly. It stopped crashing so this was probably a stale change in my local tree, apologies for the confusion. Thanks a lot for the nice collaboration here!

Changed in midori:
status: In Progress → Fix Committed
Cris Dywan (kalikiana)
Changed in midori:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.