The Android WebView saves developers a lot of time by making web content available inside of apps. It’s great as long as it works the way it’s intended to!
If you use an Android phone, no matter if it’s one of the best Android phones or a great cheap Android phone, chances are you had problems with a lot of apps on Monday evening. When a group of otherwise working apps starts to crash and burn, there is usually a single culprit responsible, and this time it was a wonky update for the Android System WebView component.
You might be wondering what Gmail, Google Maps, and even Instagram have in common that could cause all three to stop working when a small, mostly unknown component goes haywire. That’s something we can tear apart and talk about. So with that in mind, let’s jump right into our Android System WebView explainer.
What is the Android System WebView?
A lot of the apps you find in the Google Play store need to show you something from the internet. Pretty much every single one of Google’s services is web-based, your social media is all hosted on a web server, and even many games are played through the web and need some component that acts as a web browser to work properly.
You can easily picture this yourself by opening the Chrome browser and visiting www.gmail.com, where you’ll see the URL change as you’re directed to a web app where all your email lives. It looks a little different than the Gmail app does, but all the content is in place. Of course, this works from any desktop web browser, too.
WebApps can be great, but a dedicated app usually offers more features.
It would be easy to make an app that’s really nothing except a web shortcut to gmail.com, but having a dedicated app makes for better notifications, and some of Android’s other tools can be incorporated by using app permissions. Plenty of apps and services will work just fine in Chrome through the appropriate site, but usually, having an app makes for a better user experience.
Rather than having every app use its own built-in web browser that can render the same way Google Chrome’s blink engine does, Google has provided a built-in system component that just works; when it’s working, that is. Think of the Android System WebView as a Chrome tab without all the extra junk Chrome has going on like synchronization or a set of extensions that use computational power. It’s easy, it works, it is much lighter on system resources than opening the same information in Chrome, and it saves developers a lot of time because they don’t have to build this system out on their own.
How does the Android WebView work?
The Android WebView is a slice of code that lets a developer open web content inside of their app like described above. What makes it a great idea is how easy it is to use.
A developer can add the WebView activity to an app with three short lines of code, ask for permission to use the internet, and open any web content they like with just a few more lines of code. This code doesn’t need to know what’s on the web address being used and just renders the content the same way any web browser would, including scripts.
Doing this means a developer can point a window inside of their app to a web URL, and that URL can contain dynamic content that’s updated outside of the app itself. That makes the Android WebView perfect for something like a Reddit app or your Gmail because all you need to do to see any new or changed content is to refresh the page.
It would be incredibly difficult to build a web service and a corresponding app that was always up to date without using a slice of the actual web page for the service. With Google providing a system-wide method to grab those slices of the web, it can maintain standards and everything can be kept up to date by Google rather than every developer fending for themselves. Most modern operating systems have a similar way to display dynamic web content inside of an application.
What happens when the WebView crashes?
A lot of apps stop working, as we saw on March 22, 2021.
An update for the Android System WebView (you update this particular system component through Google Play) turned out to be a little funky that afternoon, and the result was apps that depended on the Android WebView could no longer display the content they needed. It didn’t affect everyone, and there seems to be no rhyme or reason to explain the bug. The good news is that it was quickly patched, and as long as you’ve updated Chrome and the Android WebView „app,“ everything is good to go once again.
This really shows why the system that Google has in place here is so great, and how so many other apps depend on it working correctly. If this bug affected you, having a lot of your apps not working may not have seemed so great. But a quick turnaround and a fix pushed to every user all at once almost makes up for it.
It also shows how careful Google needs to be anytime it updates a system component. A quick fix is great but having millions of users with apps not working because of your bug certainly isn’t. Something like the Android WebView is pretty well tested before it gets pushed out, but bugs still happen. How quickly they are found and fixed is even more important than preventing them in the first place.
The Android WebView isn’t something glamorous, nor is it one of those things we talk about a lot. It usually just sits there and does its job, and we really don’t care about it. But it’s still kind of cool to know how all this works and just how dependant on the internet our phones really are.
Android Central – Android Forums, News, Reviews, Help and Android Wallpapers