Privacy is hitting the mainstream, the cows are smelling hamburgers and asking questions (Update: I’ve tested some benchmarks on ad-blocking in various configurations here). Apple is finally rolling out an ad-blocking feature in Safari 9, with the following official description:
“The new Safari release brings Content Blocking Safari Extensions to iOS. Content Blocking gives your extensions a fast and efficient way to block cookies, images, resources, pop-ups, and other content. Your app extension is responsible for supplying a JSON file to Safari. The JSON consists of an array of rules (triggers and actions) for blocking specified content. Safari converts the JSON to bytecode, which it applies efficiently to all resource loads without leaking information about the user’s browsing back to the app extension.”
Makes perfect sense – sites deprived of their ad revenue look elsewhere, like pushing native apps onto users, where tracking and ads can’t be blocked, or use Apple iAds platform. Either way, Apple gets their cut, whilst looking like the good guys for prioritizing the user experience. Or alternatively, the number of native advertisements increases exponentially, leveraging the inability of many people to tell if what they’re reading a review or an ad.
Some relevant bits on how Safari content blocker works (source):
ActionRequestHandler.swift contains a tiny amount of Swift required to bootstrap your extension. If you know Swift you can add features here, but you’ll need to use Swift 2. If you missed it, you can read my introduction to Swift 2 tutorial first.
Info.plist contains the settings for the app extension.
“…it ran your extension, fetched out the blockerList.json file, and compiled it into an optimized form representing all your rules. That optimized form is what’s given to Safari, which is why this new model is so much faster – extensions don’t link into Safari at all, they just provide rules once, up front, then let Safari do the rest.”
Helpfully, one of the WebKit engineers confirmed to me that they expect to allow 50,000(!) rules per extension.
A list of content types that can be blocked (1st and 3rd party, with regex URL matching), (in-depth source):
- “raw” (any untyped load, like XMLHttpRequest)
This is very comprehensive, on par with uBlock Origin on other platforms (to date the most comprehensive and customizable ad-blocker) and if the ad-blocker itself is created properly, then I am certain 50,000 rules would be sufficient for most people. The implemention then boils down to whitelist/blacklist capabilities and the source of the rules (ie. hosts sources). My current hosts file is around 150,000 domains long and it’s reasonably comprehensive. I’ve seen hosts file go up to 50MB (4.5 million+ hosts) before, but that’s a niche case. You can read Adblock Plus’s response here, basically their filter lists are not compatible.
Note that content blocking applies ONLY to the Safari view controller. There is also significant difference between ad-blocking (of mostly cosmetic benefit to the user), with user tracking. Often both are rolled into websites, but tracking can exist without any visible ads being seen at all, it’s loaded in the background silently. Similarly, tracking is nearly always built into downloaded apps, for a variety of reasons. Developers can track your usage habits, and in some cases feed back your email address, unique ID, rough location (based on wifi networks) and other details for unknown uses. For now, let’s ignore that.
The good news is that the Safari view controller (which supports the content blocker extension), is able to be implemented in third-party apps, replacing their own in-app browsers. If this is the case, and the app decides to do so, then ad-blocking will be available in those apps, as per the extension rules. Combined with deep-linking, this could be a very good thing. I am fairly certain than WKWebview will not receive content blocking capabilities, this includes Google Chrome, which uses WKWebview.
Tangentially, it’s worth mentioning that mobile Chrome, on every platform, doesn’t support Extensions at all. I suspect this is not for a technical reason (mobile Firefox has supported it’s more complex XUL addons for a while), but that Google knows the number one extension installed will be an ad-blocker. People hate floating ads, massive banners, interstitials and all other manner of space-hogging, bandwidth-slurping ads. Bottom line – if you’re using Android, either apply a hosts file, or use Firefox + uBlock Origin. The reason I would never recommend using Adblock Plus is that the method it uses to block ads (injecting frames everywhere), is extremely memory and CPU intensive. In addition, they take money for allowing ads through. Use uBlock Origin instead.
If you’re interested to see what mobile ad-blocking can do, uBlock Origin has been available for mobile Firefox for a while, and it allows extremely fine and granular controls including a wide range of ad-blocking sources. Ad-blocking has also been available for all desktop browsers for a while. Make sure you use uBlock Origin, it has the most features, the least bloat, and the developer Raymond Hill has virtuously refuses to take donations. He made the non-Origin uBlock originally, handed it off to a volunteer, Chris, who then promptly tried to monetize every part of it. Raymond then resumed development under the uBlock Origin moniker, with the non-Origin uBlock stagnating.
A browser-based content blocker will do nothing to stop tracking in every other part of the OS. There’s only really one way tried-and-tested way of stopping that, and that’s a hosts file. All connections going to a known blacklist (often of hundreds of thousands or millions) of known advertising or third-party tracking servers are sent into a black hole. The blocking is done universally, regardless of any settings in the OS or in any app. It takes no additional CPU cycles and requires no installation of addons. However, on all systems, you will require root/administrator/jailbreak access to apply a hosts file.
What I expect to happen in the immediate future is because the least-technically inclined users with the most spendy habits now have access to ad-blocking, sites will resort to using more nefarious means. Things like same-domain ad hosting, or randomized CSS naming could be implemented. More paywalls, more subscription nagging, more urgency in ‘Install Our App!’ messages.
For tracking, techniques like canvas fingerprinting, supercookies, ETags / DOM storage, or plain old browser fingerprinting have already been in use for a while, rendering VPNs/proxies ineffective for privacy. These techniques are incredibly difficult to stop, even on desktop browsers, but you can get close. That information can then be cross-matched against where users are seeing ads – whether it’s tailored native advertisements, or Apple ‘approved’ ads in iAds/News, or installed apps. One thing that you won’t see if wholesale moving to a subscription model, people love free things too much. Prepare for wave two of the ad wars, the one that happens in the background.