The Safari View Controller

Deep linking takes care of the situations where a link in an application redirects to Safari. However, there are other ways that developers can handle links in their applications. The other major method is one you’ll find in apps like Skype and Facebook, and it’s basically a mini web browser built inside the application. These built in web browsers traditionally used UIKit’s UIWebView class, which was subject to performance constraints when compared to mobile Safari. iOS 8 introduced the WKWebView class which was just as fast as Safari, but had some issues of its own that made it difficult to implement in many situations. While iOS 9 fixes many of the issues with WKWebView, such as lack of support for loading local files with the file://URL protocol, it also comes with a much better method for developers to handle the transition from their app to Safari. This new feature is called the Safari View Controller.

The main reason for Safari View Controller’s existence is to provide a better user experience than the existing miniature web browsers that applications have built in to them to handle web links. When an application handles the rendering of web pages on its own, the user loses access to many features of Safari like their password keychain, their stored credit card info, their cookies, and more. The obvious solution to this is to just use Safari, but that has traditionally come with the cost of moving the user out of their current application. This is certainly improved with the addition of the back link in iOS 9, but it would be much better if those mini web browsers could just be replaced by Safari running inside of an application. That’s essentially what Safari View Controller is.

When an application uses Safari View Controller to handle web content, the user will be presented with the interface above after clicking on a link. It’s very similar to Safari’s interface, but with a few alterations to let the user know what has happened. For starters, there’s a button in the upper right that says “Done”, which is a fairly obvious control to return to the application. The URL bar at the top is also greyed out, which indicates that you can’t change it. If you do want to start surfing the web, there’s a button in the bottom right to open the actual Safari application. Developers can also specify a custom tint color for the UI so users remember what application they’re working within.

While Safari View Controller gives the user access to all of their data like passwords, credit cards, and cookies, none of this information is provided to the host application. This is because Safari View Controller is actually running in a completely separate sandboxed application, which means that users don’t have to worry about the security of what they input or where they visit. This is also helpful for developers who don’t want to deal with the privacy implications of having users input into their own built in mini browser. What’s also useful for both developers and users is the ability to specify custom options in the Safari View Controller share sheet, such as a button that can share the current web page to a social network or to a contact via an instant message.

Since applications haven’t taken advantage of Safari View Controller yet it’s difficult to really communicate the advantages it provides. However, I think everyone can appreciate the improved user experience that comes with having access to all your web browser content in a safe and secure manner within any application. Since Safari View Controller also makes a developer’s life a lot easier by taking away the need to build a mini web browser UI, I think it will see significant and speedy adoption among new and existing applications.

Safari Content Blockers

I mentioned earlier in the review that Apple News ends up freeing you from the terrible ads, trackers, and slow JavaScript code of the modern web. However, the fact of the matter is that almost every user will have to use Safari or another web browser to do things on their phone, and most will use one on a daily basis. If your task isn't reading news, then Apple News can't protect you from the cruft of the web. One solution is to use native apps for websites, but it's hardly the case that every website offers their own app. The other solution is what we get in iOS 9, with a new Safari feature called Content Blockers.

Safari Content Blockers are extensions that provide Safari with a list of rules which defines content or resources on webpages that should not be shown or even loaded. The list of rules is written in JSON, and the syntax is simple enough that it really wouldn't be that difficult for most people to figure out how to make their own Content Blocker on their own. Having a relatively user-friendly syntax is also important because iOS 9 now allows you to sideload applications and extensions without having to pay the yearly $99 for an iOS developer account so long as you're compiling from source. This means that users can write and install their own Content Blocker with Xcode, or download and install an open source one from the web.

Pretend that you're reading AnandTech, and you're really annoyed at the Twitter sidebar on the right for whatever reason. You decide to write a Content Blocker to remove it, and the code for that blocker is what's shown in the Xcode project window above. As you can see, it's fairly readable code. The action applies the css-display-none attribute to page elements matching the selector, which is article.twitter in this case. For the trigger section we have the url-filter set to .* which means anything, as we want to indiscriminately eradicate every part of the Twitter feed. To make sure it doesn't affect content on other sites we tell it to only apply if the domain matches AnandTech.com or any of its subdomains.

Once you install an application that provides a Content Blocking extension, a new Content Blocker menu will appear in the Safari section of the settings app. In that menu you can enable or disable the Content Blockers that exist on your device. There's not much more to it once you enable the Content Blocker. If you were to install this and load any page on AnandTech the Twitter sidebar would be completely gone. It's worth noting that Content Blockers can only be installed on ARMv8 devices, which limits it to any device with Apple's A7, A8, or A8X SoCs.

While blocking specific content is one application of Content Blockers, you can create rules that apply to large swaths of content. The application that I'm sure many users are thinking of is blocking advertisements, and trackers. It is true that you can make Content Blockers to remove advertising, and I have no doubt that there will be ad blocking apps available very soon. As a writer, I can only do my job because this website is funded by advertising revenue, which would disappear if everyone blocked ads. At the same time, I recognize the fact that ads almost always come along with privacy violating tracking, garbage JavaScript code, and a long period of network activity which keeps your device's radio working and drains your battery. I'm not going to get involved in the debate about the ethics of ad blocking, but I did make an ad blocker for AnandTech to show what changes it makes to load times and page sizes.

The top image show a timeline of the network activity, page rendering, and JavaScript execution for the AnandTech home page without any advertisements or tracking scripts disabled. The bottom shows those same metrics when they are all blocked using a Content Blocker that is only a couple of lines longer than the one above I used to remove the Twitter sidebar. As you can see, the difference is absolutely enormous. Without Content Blocking it takes 1.43 seconds to just load in the core site content, which is over double the amount of time with Content Blockers. 1.43 seconds doesn't sound like a lot when it's not even one second longer, but it's extremely noticeable once you see how quickly the page loads with the blockers. There's also a 2.5MB reduction in data usage, and it's worth noting that there are sites that load even more than 3.5MB with ads. I'm not in the business of public shaming, but other people have already published the results of using Content Blockers on other websites and all I can say is that while 3.5MB is not amazing, it can get even worse.

The most shocking thing of all is the reduction in network traffic. With no ads firing trackers your network requests end when the page loads. Without the Content Blockers you can see that the network requests continue. The results vary, but I've seen it go as long as 25 seconds. Those 25 seconds are a period where your data is being used, and your radio is actively in use which is draining your battery without you even knowing it.

Like I said before, I'm not going to take a stance for or against adblocking. I will say that as a user, one never really gives explicit permission to be tracked, and it's just implied by your use of a service which makes it less clear to the user what exactly they're consenting to. I'll also say that the ad experience on the web is nothing short of terrible. If ad blocking becomes a big thing in mobile the publishers and ad networks are going to have to fix the intrusiveness and slowness of ads, or move inside applications like Apple News where another company that does know how to implement them in a user friendly manner can do it for them.

Under the Hood: UI Navigation, Input, App Thinning Final Words
Comments Locked

227 Comments

View All Comments

  • Speedfriend - Thursday, September 17, 2015 - link

    @melgross I have recently seen numerous tablets being used by businesses (restaurants, delivery companies) that were clearly no-name Android tablets designed for that specific tasks. Why would a corporate that needs a tablet for a single task buy a $500 iPad when they can get a $200 Android?

    iPad is now caught in the middle between cheap single task Androids and multi-task windowns 2-in-1s. Our CEO is obsessed with Apple products but we have gone Windows tablets and it looks like we are going to go full surface range soon (3 and Pros). Why, because an iPad is too limited even as something you just take to meetings with you.
  • FunBunny2 - Wednesday, September 16, 2015 - link

    -- a respected history of hardware-design and innovation..

    really, really now? Apple has always bought their silicon, 99.44% is off-the-shelf. Yeah, I know, the fanbois brag that the Ax chips are somehow blessed by Apple. Fact is: Apple only tweaked around the edges, using industry standard silicon design tools, a bit of cache added here and there. Just look at the BoM from any of the usual teardown sites. You'll see the fact: it's always other people's parts.
  • osxandwindows - Wednesday, September 16, 2015 - link

    So why is apple not using 8core chips ha?
  • Intervenator - Wednesday, September 16, 2015 - link

    I hope that post was sarcastic or it would really be funny.
  • damianrobertjones - Thursday, September 17, 2015 - link

    ...Because that would be too far a jump. Apple wants to MILK its customers for everything then can hence the small updates. Someone like Nokia committed a mortal sin as they released a 41Mp (36+5mp) camera phone while others are still messing with 20Mp.

    All about the cash.

    P.s. Android NEEDS more cores as it runs like a bag of crap.
  • calden - Monday, September 28, 2015 - link

    Actually Android runs just as smooth as iOS. The problem is skinned, custom versions of Android, i.e. TouchWiz. When I replaced TouchWiz with CM 12.1 on my Note 4, the system took up only 580MB, where as TouchWiz took up more than 1.5GB before a single app was even installed. I also installed the launcher SmartLauncher 3, the whole experience is lightning fast. Even when running multiple apps in the background, something iOS still can't do. I think it is ridiculous that a modern OS in 2015 cannot do something as simple as stream a movie to your TV and still allow you to use the device, iOS simply pauses, even disconnects the stream in some cases if you want to do something as simple as look up an actors name in IMDB. With my Android tablet I can not only stream a film to my TV but play a game like Modern Combat 5 at the same time. As a programmer I need to run a terminal app to stay connected to my firms server during trading hours as I have monitoring tools. IOS has terminal apps as well but I can't run them them in the background the entire day without iOS terminating it's connections. Again, I find this to be absolutely ridiculous as who wants to stare at a terminal the entire day, especially when I need access to my tablet or phone to do other tasks. Apple adding Pro behind the iPad doesn't automatically make it a pro device. IOS still has one of the worst document, file management systems on the market today. My Nokia 9500 from 2004 is light years better than what iOS provides, apps should never be allowed to manage their own files. Default apps, I still can't change the default apps in iOS, why? I have no use for Apple's included apps, if I had the choice I would immediately delete them from the system, as such I need the ability to select my own browser, email client, messenger, media player, etc. as the default applications. I find this tactic of not being able to select my own default apps in iOS highly anti-competitive. The EU went after Microsoft for including Internet Explorer in XP, even though the user had the option of choosing another browser as their default. Why hasn't Apple be scrutinized about this?
  • calden - Monday, September 28, 2015 - link

    I'm aware of those few audio and GPS apps that can run in the background in IOS, but this is a far cry than allowing any app that the user needs in the background. No, this has nothing to do with battery life, if it is than Apple really needs to rewrite iOS. My BlackBerry Passport, running three apps in the background, easily lasts the entire day on a single charge, actually it lasts a day and a half with moderate to heavy use. Android has the ability to select how many apps are allowed to run in the background, you can even set it to 1. So if people feel like their apps are eating up their battery they can control the amount of running apps. Apple could easily implement such a feature, they don't though, which means they have all the control, they dictate how the user uses their own devices. iOS is a wolf in sheep's clothing, looks pretty, inviting but once you start to do real work you encounter a brick wall a 20 stories high. How many times have you iOS users logged into iCloud on your device, I had to do it over 25 times to cover every app. Why, why do I need to log in even twice, once should be enough, in Android upon setting up my Google user that was it, from that point on every app that could communicate with Google Drive would automatically be setup. This is because the apps talk to the system at the lowest level, iOS requires spaghetti API's, a spiderweb of tunnels trying to pass info to each other. The Share TO function in iOS works only if the app dveloper has created a share profile. Why can't the system just dynamically create these Share To lists like Android 5.1.2, SailFish 2.0, Windows Mobile 10, BlackBerry OS 10.3.2 by looking for every compatible app that is installed and than listing. No, instead iOS uses this half ass API system. What about mult-user support, will never happen in iOS because of the way it handles files. To support multi-users in iOS each user would have to reinstall each app over again to distinguish each users. They could embed the users info in the file's metadata so the app can distinguish each user but that is just hacky at best would and how would these modified files react when used on other systems. IOS is definitely not a pro system and anyone thinking differently is either lying to themselves to protect their beloved Apple brand, aren't professionals themselves so don't reall understand the meaning or are working around these limitations, fighting the system at every point to get their work done which falls in line with point one, their lying to themselves.

    I'm not saying that iOS devices don't have their uses, they do. They make great consumer devices for media consumption, social media, gaming, drawing and other artistic apps, music and music creation, etc. However as a productivity tool these devices are highly limited and can't compete with the likes of a Surface Pro 3 or even Surface 3. Even an Android tablet would be a better option. With my Nexus 9 I can log into the LDAP and gain access to all my allowed users NAS storage, mount it as a local asset. Set file extensions to open up certain apps, etc. Trying to do this in iOS is like trying to put a round peg into a square one. You can do it with a bit of force but your going against it's designed purpose. Apple needs to completely rewrite iOS, combine many functions found in OSX before I would ever consider using another mobile device from Apple.
  • mikhapop - Monday, September 28, 2015 - link

    you really nailed it, i am a web developer and i often fail to tell my friends how the ios is very limiting for even the basic stuff (my basic stuff). android is far better as far as the os go. Now i am using a surface pro 3 and never looked back, very good in meetings, and it is now my main machine for 98% of my work.
  • blackcrayon - Wednesday, September 16, 2015 - link

    Sounds like you know close to nothing about the Ax chips. They are custom Apple designs, and they also optimize their OS for them. I bet you thought Intrinsity and PA Semi were just marketing facades that didn't actually do anything before Apple acquired them years ago, right?
  • KoolAidMan1 - Wednesday, September 16, 2015 - link

    Apple spent billions acquiring semiconductor companies and is one of the few companies along with Qualcomm that has a license to make ARM chips. Anand himself highlighted this while showing that Apple's custom designs matched or exceeded Intel's Bay Trail.

    You really think their custom designs are something to be dismissed just because of the name on the package? The fanboy is strong in your posts

Log in

Don't have an account? Sign up now