On June 5, Apple announced their annual update to various products at the WWDC 2017 Conference during their keynote session.
While a lot gets presented at these keynotes each year, rarely do web-based technologies get much attention beyond performance benchmarks and user experience tweaks. Web developers generally need to hunt down the release notes, download the beta releases, and give the browsers a try themselves.
The reason I say “browsers” and not “browser”, is mobile Safari and desktop Safari are slightly different in capabilities.
Thankfully, for nearly a year now the WebKit team have been releasing regular “Safari Technology Preview” builds that can be used to test forthcoming features for desktop Safari.
For mobile Safari however, developers can only guess which features may or may not come out with the next iOS. There are no stand-alone mobile previews to download, and until a new iOS beta comes out we can’t know what features Apple plans on allowing into the next mobile browser version.
Not everything that makes it to the desktop is added to the mobile version. One of the most notable features missing from mobile Safari is Web Notifications, of which the desktop version has enjoyed for years now.
What’s new for Safari 11
The official Safari 11 release notes include the following that are of interest to me:
- WebRTC implementation for conferencing
- getUserMedia/Stream API - browser can now access video & audio directly in real-time
- Web Assembly (this alone is huge!)
- updated WebKit support for home screen web apps
Of those, the combination of WebRTC and Stream API finally give the web some more equal playing ground with native apps when it comes to working with the camera and microphone. Until Safari 11, the only way one could work with either of these was through file uploads – you could take a photo, record a video, but any processing of data in either media would have to be done after the recording was done.
With these updates, real-time reactions to the content – such as making a QR code scanner, or streaming a voice message direct to a server as you talk are finally possible. This also opens up Augmented Reality (AR) possibilities as well, especially with the huge added processing firepower that comes with Web Assembly.
None of these features would be very interesting for me if Safari wasn’t the last hold-out of these standards. With the release of Safari 11, WebRTC and Stream API are real, implemented cross-platform standards. (Web Assembly is really close, with Microsoft Edge browser as the last hold-out – and that won’t be for long as I’d expect to see it in Edge 16.)
Playing with Safari 11.0
I’ve played around a bit with Safari on the iOS 11 Beta, and there’s a few interesting finds I’ve had…
- The User-Agent String diverges from desktop
- Strangely, while it does indicate iOS 11 in the string, it identifies as Safari 10.0. This might not be a mistake: iOS 10.1, 10.2, 10.3 all identified as using Safari 10.0 even though iOS 10.3 used Safari 10.1. This would be far from the first time a browser has decided to do strange things in the user agent string. Why would they do this? No ideas.
- getUserMedia (Stream API) doesn’t entirely match the W3C spec
- Stream API’s
facingModeconstraint does not use the standard
environmentkeywords to refer to the front-facing and rear-facing camera as per the W3C recommendation. While
userworks for front-facing,
environmentalso utilizes the front-facing camera – it shouldn’t, it should face the “environment”. To use the rear camera, the keyword
rearmust be used. (I’m not convinced
useris actually accepted necessarily, but anything other than
rearseems to fallback on front-facing – my bet is Safari prefers
- Stream API’s
- StreamAPI continutes to work in the background if you switch tabs
- You can continue streaming audio & video while browsing another tab in Safari, though you cannot leave Safari entirely while doing so. If you multi-task and open a second app alongside Safari, it seems to pause the streaming, though I’m not 100% sure of this
- Home screen web apps attempt to resume when restored, but crash
- In all previous iOS versions, “home screen” (fullscreen) web apps would restart anytime you switched away from them to another app. In iOS 11 this does not happen… but it does happen. Rather than immediately restarting the web app over again, it appears to briefly attempt to restore it, then crashes to the home screen. Then you have to launch it again. I hope web app sessions can be switched to, and that the crash is just a bug.
These are what I’ve found so far. I plan on following up with a proof-of-concept cross-platform QR scanner to demonstrate how Stream API can be used. I’ve done a few tests, and it is pretty quick. I would love to try and make it even faster with a compiled Web Assembly module, but that would probably take much more time.