Bug 188843 - NetworkCache::Storage::lastStableVersion should be a developer-only feature
Summary: NetworkCache::Storage::lastStableVersion should be a developer-only feature
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-22 07:29 PDT by Antti Koivisto
Modified: 2018-08-23 00:00 PDT (History)
9 users (show)

See Also:


Attachments
patch (2.87 KB, patch)
2018-08-22 08:10 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2018-08-22 07:29:03 PDT
System WebKit should always delete old cache versions.
Comment 1 Antti Koivisto 2018-08-22 07:29:14 PDT
<rdar://problem/43574100>
Comment 2 Antti Koivisto 2018-08-22 08:10:09 PDT
Created attachment 347792 [details]
patch
Comment 3 Michael Catanzaro 2018-08-22 09:08:30 PDT
Comment on attachment 347792 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=347792&action=review

> Source/WebKit/Shared/mac/ChildProcessMac.mm:743
> +#if PLATFORM(MAC)
> +bool ChildProcess::isSystemWebKit()
> +{
> +    static bool isSystemWebKit = [] {
> +        return [[webKit2Bundle() bundlePath] hasPrefix:@"/System/"];
> +    }();
> +    return isSystemWebKit;
> +}
> +#endif

You can implement this now for all platforms. On non-Cocoa ports, it's system WebKit #if !ENABLE(DEVELOPER_MODE).
Comment 4 Michael Catanzaro 2018-08-22 09:09:28 PDT
BTW it would be convenient if ENABLE(DEVELOPER_MODE) was defined on Cocoa ports as well. Currently that only works for CMake ports (so all non-Cocoa ports).
Comment 5 Daniel Bates 2018-08-22 13:34:11 PDT
Comment on attachment 347792 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=347792&action=review

> Source/WebKit/Shared/mac/ChildProcessMac.mm:740
> +    static bool isSystemWebKit = [] {
> +        return [[webKit2Bundle() bundlePath] hasPrefix:@"/System/"];
> +    }();

This will treat an installed development WebKit root or Xcode installed development WebKit as a system install. Is this OK? Otherwise, we should make use of the codesign framework API/SPI to actually check that the process is "restricted" and/or signed by Apple.
Comment 6 Geoffrey Garen 2018-08-22 14:50:10 PDT
I think it's OK to treat installing roots as an "upgrade" event that clears old caches just like a real upgrade would.
Comment 7 Geoffrey Garen 2018-08-22 14:55:14 PDT
> BTW it would be convenient if ENABLE(DEVELOPER_MODE) was defined on Cocoa
> ports as well. Currently that only works for CMake ports (so all non-Cocoa
> ports).

I read some of the DEVELOPER_MODE code and I'm not sure I fully understand the concept -- or perhaps I disagree with it. In general, we want the code we test to be the same as the code customers will run. That way, we know that our testing is accurate. But DEVELOPER_MODE seems to be a step away from that.

Maybe you should send email to webkit-dev explaining the thesis of DEVELOPER_MODE and some examples of when to use or not use it. Then we can discuss.
Comment 8 Geoffrey Garen 2018-08-22 14:55:38 PDT
Comment on attachment 347792 [details]
patch

r=me
Comment 9 Michael Catanzaro 2018-08-22 15:51:55 PDT
Well the thesis is straightforward: sometimes you really do need to do things differently for developers. For instance, the title of this changelog:

"NetworkCache::Storage::lastStableVersion should be a developer-only feature"

Normally we use it for loading content from the source directory rather than the install prefix. E.g. in developer mode, hyphenation dictionaries, secondary processes, and the InjectedBundle are all loaded from the source directory instead of the install prefix. It would not be very good for developers if the UI process were to try launching the system WebKitWebProcess, for example.

Anyway, you don't need to enable it for Cocoa here, but you should use it here for other ports, because this is exactly the sort of thing it's intended for. E.g.:

bool ChildProcess::isSystemWebKit()
{
#if ENABLE(DEVELOPER_MODE)
    return false;
#elif PLATFORM(MAC)
    static bool isSystemWebKit = [] {
        return [[webKit2Bundle() bundlePath] hasPrefix:@"/System/"];
    }();

    return isSystemWebKit;
#else
    return true;
#endif
}

and then you can remove the other PLATFORM(MAC) guards:

#if PLATFORM(MAC)
    /// Allow the last stable version of the cache to co-exist with the latest development one.
    static const unsigned lastStableVersion = 12;
#endif

#if PLATFORM(MAC)
            if (directoryVersion == lastStableVersion)
                return;
#endif

since clearly there's nothing really platform-specific there.
Comment 10 Antti Koivisto 2018-08-22 23:42:22 PDT
> since clearly there's nothing really platform-specific there.

The 'stable version' here refers to the version a developer likely has installed as system WebKit. That is platform specific. 

(the idea is to prevent newer builds of WebKit unnecessarily wiping out the caches for the system WebKit)
Comment 11 WebKit Commit Bot 2018-08-23 00:00:15 PDT
Comment on attachment 347792 [details]
patch

Clearing flags on attachment: 347792

Committed r235220: <https://trac.webkit.org/changeset/235220>
Comment 12 WebKit Commit Bot 2018-08-23 00:00:17 PDT
All reviewed patches have been landed.  Closing bug.