Skip to content

Commit

Permalink
Merge branch 'main' into sam/persistent-pixels
Browse files Browse the repository at this point in the history
* main:
  Release 7.141.0-0 (#3435)
  Add error handling to contrainer removal (#3424)
  Prevent autofill prompt crash for edge case where a context menu is also visible on screen (#3417)
  • Loading branch information
samsymons committed Oct 14, 2024
2 parents 154506c + d82a840 commit e3c8665
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 7.140.0
MARKETING_VERSION = 7.141.0
4 changes: 2 additions & 2 deletions Core/AppPrivacyConfigurationDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import BrowserServicesKit
final public class AppPrivacyConfigurationDataProvider: EmbeddedDataProvider {

public struct Constants {
public static let embeddedDataETag = "\"6330c36f7ff354d26f32ee951e0a972e\""
public static let embeddedDataSHA = "40f77d6db1db544f06740b3290c5a72e5f03f706d17c9c0e05b13cd9255f2778"
public static let embeddedDataETag = "\"4ffe7d2b6c8e252d0289b1398cc2685d\""
public static let embeddedDataSHA = "9795ade4fdbc474688250f2ecfa097e917feea21a54fd97c524b851245d170e8"
}

public var embeddedDataEtag: String {
Expand Down
40 changes: 34 additions & 6 deletions Core/WebCacheManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,29 @@ public class WebCacheManager {
dataStoreIdManager: DataStoreIdManaging = DataStoreIdManager.shared) async {

var cookiesToUpdate = [HTTPCookie]()
var leftoverContainerIDs = [UUID]()
if #available(iOS 17, *) {
cookiesToUpdate += await containerBasedClearing(storeIdManager: dataStoreIdManager) ?? []
let result = await containerBasedClearing(storeIdManager: dataStoreIdManager)
cookiesToUpdate += result.cookies
leftoverContainerIDs = result.leftoverContainerIDs
}

// Perform legacy clearing to migrate to new container
cookiesToUpdate += await legacyDataClearing() ?? []

cookieStorage.updateCookies(cookiesToUpdate, keepingPreservedLogins: logins)

// Attempt to clean up leftover stores again after a delay
// This should not be a problem as these containers are not supposed to be used anymore.
// If this fails, we are going to still clean them next time as WebKit keeps track of all stores for us.
if #available(iOS 17, *), !leftoverContainerIDs.isEmpty {
Task {
try? await Task.sleep(for: .seconds(3))
for uuid in leftoverContainerIDs {
try? await WKWebsiteDataStore.remove(forIdentifier: uuid)
}
}
}
}

}
Expand All @@ -113,18 +128,27 @@ extension WebCacheManager {
}

@available(iOS 17, *)
private func containerBasedClearing(storeIdManager: DataStoreIdManaging) async -> [HTTPCookie]? {
private func containerBasedClearing(storeIdManager: DataStoreIdManaging) async -> (cookies: [HTTPCookie],
leftoverContainerIDs: [UUID]) {
guard let containerId = storeIdManager.currentId else {
storeIdManager.invalidateCurrentIdAndAllocateNew()
return []
return ([], [])
}
storeIdManager.invalidateCurrentIdAndAllocateNew()

var leftoverContainerIDs = [UUID]()

var dataStore: WKWebsiteDataStore? = WKWebsiteDataStore(forIdentifier: containerId)
let cookies = await dataStore?.httpCookieStore.allCookies()
let cookies = await dataStore?.httpCookieStore.allCookies() ?? []
dataStore = nil

var uuids = await WKWebsiteDataStore.allDataStoreIdentifiers

// There may be a timing issue related to fetching current container, so append previous UUID as a precaution
if uuids.firstIndex(of: containerId) == nil {
uuids.append(containerId)
}

if let newContainerID = storeIdManager.currentId,
let newIdIndex = uuids.firstIndex(of: newContainerID) {
assertionFailure("Attempted to cleanup current Data Store")
Expand All @@ -133,11 +157,15 @@ extension WebCacheManager {

let previousLeftOversCount = max(0, uuids.count - 1) // -1 because one store is expected to be cleared
for uuid in uuids {
try? await WKWebsiteDataStore.remove(forIdentifier: uuid)
do {
try await WKWebsiteDataStore.remove(forIdentifier: uuid)
} catch {
leftoverContainerIDs.append(uuid)
}
}
await checkForLeftBehindDataStores(previousLeftOversCount: previousLeftOversCount)

return cookies
return (cookies, leftoverContainerIDs)
}

private func legacyDataClearing() async -> [HTTPCookie]? {
Expand Down
71 changes: 57 additions & 14 deletions Core/ios-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"readme": "https://github.com/duckduckgo/privacy-configuration",
"version": 1728095993160,
"version": 1728900024972,
"features": {
"adClickAttribution": {
"readme": "https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/#3rd-party-tracker-loading-protection",
Expand Down Expand Up @@ -370,10 +370,7 @@
],
"settings": {
"disabledCMPs": [
"generic-cosmetic",
"termsfeed3",
"healthline-media",
"ketch"
"healthline-media"
]
},
"state": "enabled",
Expand All @@ -396,7 +393,7 @@
}
}
},
"hash": "cc06869d3abb10ef0570aa68829cc37b"
"hash": "ea2fef42c1666e9d9e4cabd49e57764d"
},
"autofillBreakageReporter": {
"state": "enabled",
Expand Down Expand Up @@ -1462,7 +1459,8 @@
"state": "disabled"
},
"enableDuckPlayer": {
"state": "internal"
"state": "enabled",
"minSupportedVersion": "7.139.0"
}
},
"settings": {
Expand Down Expand Up @@ -1499,7 +1497,8 @@
".ytd-video-preview",
"#thumbnail-container",
"#video-title-link",
"#video-title"
"#video-title",
"video.video-stream.html5-main-video"
]
},
"thumbnailOverlays": {
Expand Down Expand Up @@ -1549,8 +1548,8 @@
}
]
},
"state": "internal",
"hash": "887a8548cb01c9568e4d1b4d195af88b"
"state": "enabled",
"hash": "7f82d68f07b3e2aaac1b89725c1d379e"
},
"elementHiding": {
"exceptions": [
Expand Down Expand Up @@ -3444,6 +3443,15 @@
}
]
},
{
"domain": "livebeaches.com",
"rules": [
{
"selector": "[class*='random-ad']",
"type": "hide-empty"
}
]
},
{
"domain": "livemint.com",
"rules": [
Expand Down Expand Up @@ -4860,7 +4868,7 @@
]
},
"state": "enabled",
"hash": "ee31df28088021bca94518f6f8c63ce9"
"hash": "91a3dbe67daa37762247c415766a2634"
},
"exceptionHandler": {
"exceptions": [
Expand Down Expand Up @@ -5275,6 +5283,9 @@
{
"domain": "jcrew.com"
},
{
"domain": "pgealerts.alerts.pge.com"
},
{
"domain": "marvel.com"
},
Expand Down Expand Up @@ -5303,7 +5314,7 @@
"privacy-test-pages.site"
]
},
"hash": "dfbfd6b6e23a093d562989baa78a2f25"
"hash": "fb031f27a1e1c2b143505c4f2e7b3ba7"
},
"harmfulApis": {
"settings": {
Expand Down Expand Up @@ -7404,6 +7415,7 @@
"local12.com",
"local21news.com",
"midmichigannow.com",
"mlb.com",
"my15wtcn.com",
"my24milwaukee.com",
"my48.tv",
Expand Down Expand Up @@ -7997,7 +8009,7 @@
"nosto.com": {
"rules": [
{
"rule": "connect.nosto.com/script/shopify/nosto.js",
"rule": "connect.nosto.com",
"domains": [
"<all>"
]
Expand Down Expand Up @@ -8383,6 +8395,7 @@
"rule": "a.pub.network/core/prebid-universal-creative.js",
"domains": [
"signupgenius.com",
"smithsonianmag.com",
"titantv.com"
]
},
Expand Down Expand Up @@ -8527,6 +8540,16 @@
}
]
},
"sascdn.com": {
"rules": [
{
"rule": "sascdn.com/tag/",
"domains": [
"filmweb.pl"
]
}
]
},
"scene7.com": {
"rules": [
{
Expand Down Expand Up @@ -8651,6 +8674,16 @@
}
]
},
"smartadserver.com": {
"rules": [
{
"rule": "smartadserver.com/genericpost",
"domains": [
"filmweb.pl"
]
}
]
},
"snapkit.com": {
"rules": [
{
Expand Down Expand Up @@ -9181,6 +9214,16 @@
}
]
},
"eltiempo.co": {
"rules": [
{
"rule": "ads.eltiempo.co/genericpost",
"domains": [
"filmweb.pl"
]
}
]
},
"yandex.tm": {
"rules": [
{
Expand Down Expand Up @@ -9210,7 +9253,7 @@
"domain": "instructure.com"
}
],
"hash": "aacc956491f7760f65ab1c508b92b26d"
"hash": "0692c3f8cc6179433b9f23f00c7dd0ac"
},
"trackingCookies1p": {
"settings": {
Expand Down
Loading

0 comments on commit e3c8665

Please sign in to comment.