Bug 216430

Summary: [GTK][WPE] Epiphany does not make connections in Incognito Mode after clearing .cache
Product: WebKit Reporter: jpenala
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, aperez, beidson, berto, bugs-noreply, cdumez, cgarcia, mcatanzaro, youennf
Priority: P2    
Version: Other   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Screencast
none
Patch aperez: review+

jpenala
Reported 2020-09-11 23:07:35 PDT
Created attachment 408585 [details] Screencast After clearing ~/.cache, Epiphany does not connect to any site when in Incognito Mode. Checking the .cache/epiphany/adblock shows, that in Incognito, Epiphany does not download and compile the adblock list. To restore connectivity user must start in regular mode (in regular mode Epiphany downloads and compiles the adblock list), after which user can switch to Incognito mode and browse normally. Incognito Mode seems to work as long as the adblock list in .cache/epiphany/adblock is not cleared. Epiphany 3.37.91, Fedora 33, first noticed with WebKitGTK 2.29.92, issue persists in WebKitGTK 2.30.0. Downgrading to WebKitGTK 2.29.91 solves the issue: adblock list is downloaded at launch and connections work. Downstream bug report: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1331
Attachments
Screencast (1.21 MB, video/webm)
2020-09-11 23:07 PDT, jpenala
no flags
Patch (5.00 KB, patch)
2020-09-16 05:20 PDT, Carlos Garcia Campos
aperez: review+
Michael Catanzaro
Comment 1 2020-09-12 10:20:54 PDT
Hmm, not a lot changed between 2.29.91 and 2.29.92. Maybe r266389...?
Michael Catanzaro
Comment 2 2020-09-12 11:17:50 PDT
(In reply to Michael Catanzaro from comment #1) > Maybe r266389...? Yup, that's it. But that commit looks like an important fix that probably should not be reverted. I have not investigated further yet, but my guess is the adblocker is unable to download adblock filters because it's blocked waiting for itself to download adblock filters. Nothing is allowed to be downloaded until the filters are ready.
Michael Catanzaro
Comment 3 2020-09-12 11:18:08 PDT
Let's continue on Epiphany bugtracker for now.
Michael Catanzaro
Comment 4 2020-09-12 12:02:36 PDT
Reopening. I did a little more investigation, but can't find anything wrong from the Epiphany side of things. There is only one WebKitPolicyDecision involved, a navigation policy decision for ephy-about:incognito. Epiphany correctly delays that until the adblock filters are ready. There's no policy decision for the download (probably because it's started by an API request). The download just never completes. I'm not sure why, but I don't think Epiphany is responsible for this. Switching ephy_download_new_for_uri_internal() to use the default web context avoids this bug, but we shouldn't do that.
Michael Catanzaro
Comment 5 2020-09-15 07:17:09 PDT
*** Bug 216535 has been marked as a duplicate of this bug. ***
Carlos Garcia Campos
Comment 6 2020-09-15 07:27:58 PDT
I missed this bug because it was not in WebKitGTK component not webkitgtk was added to the CC. I'll check what's going on, but I ideally ephy shouldn't write anything to disk in ephemeral sessions, so adblock would only work in the rules are already there, the same way it happens with the disk cache, for example. If we want to make the adblock work in ephemeral sessions, maybe we need to add a way to download and compile the rules without writing to disk (I'm not sure that's even possible).
Michael Catanzaro
Comment 7 2020-09-15 07:54:23 PDT
Oops. :) Thanks. I think it's OK to write the adblock filters to disk because they're the same for every user; they do not contain any website data. That's why they're shared by storing them in the default cache directory instead of using the WebKitWebsiteDataManager's cache directory. There's no point in trying to avoid writing them; it would only slow down the browser for users who set the browser to always start in incognito mode, since then you'd need to wait for them to download each time you launch the browser.
Adrian Perez
Comment 8 2020-09-15 08:20:02 PDT
(In reply to Carlos Garcia Campos from comment #6) > I missed this bug because it was not in WebKitGTK component not webkitgtk > was added to the CC. I'll check what's going on, but I ideally ephy > shouldn't write anything to disk in ephemeral sessions, so adblock would > only work in the rules are already there, the same way it happens with the > disk cache, for example. If we want to make the adblock work in ephemeral > sessions, maybe we need to add a way to download and compile the rules > without writing to disk (I'm not sure that's even possible). We need a file system location for WebKitUserContentFilterStore, and there is no way around it because the files will be mmap'd and file descriptor handles passed across processes over IPC. The only option to handle filters in an ephemeral way would be to use some location under “/tmp” — and I think it should be the responsibility of the application to decide whether to do that or not.
Michael Catanzaro
Comment 9 2020-09-15 08:26:13 PDT
(In reply to Adrian Perez from comment #8) > We need a file system location for WebKitUserContentFilterStore Anyway, it shouldn't be a problem because ephy_filters_manager_constructed() ensures it uses the default cache dir rather than relying on the WebsiteDataManager. I'm not sure why the download doesn't complete.
Adrian Perez
Comment 10 2020-09-15 08:27:38 PDT
(In reply to Michael Catanzaro from comment #7) > Oops. :) Thanks. > > I think it's OK to write the adblock filters to disk because they're the > same for every user; they do not contain any website data. That's why > they're shared by storing them in the default cache directory instead of > using the WebKitWebsiteDataManager's cache directory. There's no point in > trying to avoid writing them; it would only slow down the browser for users > who set the browser to always start in incognito mode, since then you'd need > to wait for them to download each time you launch the browser. I agree with Michael here: The bytecode in filters depends only on the input JSON rules, which do not contain any user/website specific data. Epiphany adds sidecar files (a serialized GVariant) with some metadata which also does not contain any user/website specific data.
Carlos Garcia Campos
Comment 11 2020-09-16 05:16:41 PDT
The problem is that when using an ephemeral context, the download is started before the ephemeral session has been registered in the network process, so it's just ignored.
Carlos Garcia Campos
Comment 12 2020-09-16 05:20:26 PDT
Adrian Perez
Comment 13 2020-09-16 05:51:35 PDT
Comment on attachment 408916 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408916&action=review > Source/WebKit/UIProcess/WebProcessPool.cpp:1677 > + return ensureNetworkProcess(&dataStore).createDownloadProxy(dataStore, request, frameInfo, originatingPage); Wow, the subtlety!
Adrian Perez
Comment 14 2020-09-16 05:52:39 PDT
Also, this could happen with the WPE port as well (maybe others?).
Alberto Garcia
Comment 15 2020-09-16 07:14:11 PDT
(In reply to Carlos Garcia Campos from comment #12) > Created attachment 408916 [details] > Patch I confirm that this patch fixes the problem. I'm using Epiphany 3.32.1.2 in Debian buster.
Michael Catanzaro
Comment 16 2020-09-16 08:35:41 PDT
Comment on attachment 408916 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408916&action=review Nice test. >> Source/WebKit/UIProcess/WebProcessPool.cpp:1677 >> + return ensureNetworkProcess(&dataStore).createDownloadProxy(dataStore, request, frameInfo, originatingPage); > > Wow, the subtlety! Wow indeed.
jpenala
Comment 17 2020-09-16 09:48:26 PDT
Excellent, thank you for everyone involved!
Carlos Garcia Campos
Comment 18 2020-09-18 01:14:58 PDT
Note You need to log in before you can comment on or make changes to this bug.