Just last week, news broke out that Twitter is shutting down Periscope. This left a rather sobering reminder that paranoia in perpetuity is perhaps the only surest way to survive a dog-eat-dog world. Periscope was huge back then. Though not a user myself, I was a fan of how they were one of the first to put out a Google Play Instant version of their app and made it to Google I/O 2017 to talk about their experience.(henceforth, I’ll use Android Instant App to refer to Google Play Instant, which was the original nomenclature for the feature).
In this article, I’ll share what it was like when we worked on Android Instant App at Rakuten Viki.
The year was 2016. In the keynote, one of the loudest pop from the audience comes from a rather magical feature called Android Instant Apps: a means to run native Android apps without having to install the app itself. Google announced an initial list of 66 app developers ready to get the ball rolling for this shiny new feature.
While Instant App looked cool, it was never really in our radar. In our flight back to Singapore, there’s one thing that’s running in my mind, a feature that was also announced in the conference. I’m thinking…
Can we build a Viki app for Google Daydream and transpile it to support HTC Vive, Oculus Rift, and Playstation VR?
Back in 2016, the VR hype attracted a lot of OEMs to develop their own hardware devices. We thought that by the time the market is flooded with these devices, it’d be good if we have our app there. Back in 2014 when Android TV was announced, our competitor DramaFever beat us into it by two years. Viki had a radical shift in our product ideology beginning in 2015 and between 2015 and 2018, Viki thrived in the range of products and features we churned out.¹
Anyway, back in Mountain View, I had a long chat with one engineer from the Daydream team to get an idea on how we can build Viki on it. After thinking about it and working on the first iteration of the Daydream SDK, it turned out to be too complex and risky, so we dropped the idea.
It wasn’t until June or early July, a full month and more after I/O 2016 did we start thinking about Instant App. Back then, we only had two Android engineers, myself included. At that time, my colleague Richard was working on Android TV and I was working on the mobile app. With a paltry engineering team, we are very much forced to make tradeoffs that are unsightly for engineers (i.e. incurring tech debts here and there) but served us elsewhere in pushing more user acquisitions and subscriptions (i.e. more users means more subscribers means more money to give us some runway to clean up tech debts).
We sat down with the PMs and decided that it’s worth a shot to experiment on this. So we started a conversation with Google and we got into the Early Access Program on August 1. Here’s where the insanity begins.
Google told us that they’ll be launching Instant App on August 15. That means we only have two weeks to get our app ready. You can imagine how insane this was with only two engineers and mounting tech debts.
The Road to Instant App Compatibility
There are six requirements to get an app to be Instant App compatible. Out of those six, five were quite straightforward, such as enabling App Links and so forth. The most challenging one was reducing the APK file size. At that time, our app size was around 11 MB. On the other hand, Google can only accommodate the app if it’s 4 MB or less. Remember that this was a time when Android App Bundle didn’t exist yet. So anyway we used APK Analyzer to find out how we can reduce our APK size. At that time, we have images for ldpi, mdpi, hdpi, xhdpi, xxhdpi, and tvdpi (because the original Nexus 7, which was still popular at that time, is using tvdpi, and it’s not even a TV!) At that time, the most popular pixel densities were mdpi and xxhdpi. So we decided to get rid of every other image files apart from those two because Android will automatically downsample or upscale the image anyway. That shaved off quite a bit of our file size.²
Next, we had our image files compressed with tinypng. That effectively shaved off quite a sum as well. We also noticed that font files were taking up around 1.5 MB of storage space. Remember, this was also a time when downloadable fonts were not yet supported. So we went to the design team and begged them to let us remove these custom fonts. They said yes.
By the way, in the early days of Android Instant App, ProGuard was NOT supported. Hence it spawned blogs like this which of course, Google fixed nicely several iterations later. Without ProGuard, you don’t have a means to minify your application either. This could have helped us quite a bit but anyway, this is something we have to live with.
At that point, we were still at around 5.5 MB. Without any assets or resources left to remove, we were now reduced to asking ourselves, what are the core features that need to remain?
From 5.5 MB to 4.15 MB
We decided that login must go. If we get rid of login, we can shave off around 800 KB worth of file size because of the various SSO libraries as well as features involving user login such as Viki Pass Subscription and its image assets.
With that, we are still 700 KB above the size limit. We then decided to remove every other language support apart from English. The argument was that Instant App will first launch in the US, which is largely English speaking. This saved us a further 200 KB or so.
Back in 2016, we support devices all the way back to Android 4.0, which means that we need Android’s Native MediaPlayer (ExoPlayer only supports Android 4.1 and above). However, because Instant App is only supported on Android 4.1 and above, we could remove all the MediaPlayer related code and latch on to ExoPlayer fully. So remove we did. It saved us a further 100 KB.
At Viki, we used to work with three video ad providers: Google’s IMA, Facebook Audience Network (now defunct), and Tremor (also now defunct). We decided that we really need the ad revenue from Instant App now that subscription is gone. At this point we had to choose. We decided to remove Facebook Audience Network and Tremor. That effectively shaved around 250 KB or so. We’re almost there at 4.15 MB!!
The Last Mile
At that point, we were pretty much at the end of our rope. We have removed almost everything we can remove but still have just a little bit more left. For some reason, the Google Play Services library has some assets that lingers around which we could remove. We didn’t know about this until our partner from the DevRel team highlighted this. So what we did was, after our APK is compiled, we actually ran a script to unzip the APK, specifically remove those resources, and zipped it back.
We looked at the file size: 3.98 MB. WE DID IT!!! That was around August 11. I threw myself back on my chair. Sigh of relief. We’re done. We can launch on August 15!
Launch Day: August 15, 2016
There I was on my seat at 9:00 AM Singapore Time. I waited. Waited… waited… No news. Of course, it’s still August 14 PST. So I waited.
August 16, 2016. No news.
August 17, 2016. No news either.
It turns out, Android Instant App launch was deferred to October 17. At that point, partners are dropping off left and right. Android Instant App initially had 150 developers in the program. Our DevRel told us that Viki was the first (or second) to become Instant App compatible. Of course, my tail was wagging. It was not the cleanest codebase, as the subsequent Android engineers who joined us could attest. But it was good enough to get our foot in the door. This is tremendous because Instant App was the genesis that really put us on Google’s radar. Here we are, an obscure Singapore based engineering team with so little resource serving a niche market and found ourselves to be the only App written in this side of the world to be Instant App compatible.
January 24, 2017
We woke up to the news. Google finally launched Android Instant App, five months later than initially planned. We were all over the web, alongside BuzzFeed, Wish, and Periscope. We were ecstatic.
Android Instant App was a success from the product metrics standpoint. Users who discover Viki through Instant App are 2.5x more likely to install the full app, 3x more likely to become a paying user, and watch 5x more compared to mobile web.
Viki became the poster child of Instant App in several workshops such as one which Google held in Hong Kong, Tokyo, and several other places. Viki showed up in commercials, Google Play Movies integration, and others. Here’s me playing with our Instant App at the Android booth.
Fast forward to 2019, we finally had the chance to share how we did Instant Apps to the community. My colleagues from the Viki Android team spoke about this at Android Day. Interestingly enough, I never really had a chance to speak about this in public. The reason being that the 2016 SDK of Android Instant App is nothing like that which exists today. At this point, there’s no value to talk about an SDK that’s already been replaced twice.
Funny enough, I found myself in the Google Play booth at Google I/O 2018. At this point, Google has rebranded Android Instant App to Google Play Instant. I was chatting with a few Googlers who turned out to be the team who worked on the first iteration of Android Instant App back in 2016. This was the very first time I had the chance to meet them in person. Of course, that rekindled a lot of fond memories.
This wouldn’t have been a good article without lessons learned towards the end. Here are a few of them:
Always Invest Time to Clean Up Tech Debt
In 2016, Viki moved really fast. With only two Android Engineers until Q4 of 2016, we really didn’t have time to clean up our tech debts. We were fortunate enough to have been able to go through the Instant App circus but looking back, I wish I hadn’t introduced a lot of those tech debts which they later had to clean up. In general, the product and business team should recognize that the rule of thumb is that at least 20% of engineering time must be spent on sustainability engineering (a.k.a. clearing tech debt) Product needs to understand that clearing tech debt shortens lead time and reduces change failure rate, which in turn saves money for the company.
Dare to Try, Dare to Fail
Android Instant App was an unproven feature when we invested resources on it. It was incredible because the product and engineering team were aligned to actually try this out regardless. In hindsight, luck was probably on our side. Later metrics reveal that only three categories worked well for Instant Apps: video streaming, news, and games. That said, we didn’t always succeed in our ventures. For example, we invested on projects such as co-viewing back in 2017 which turned out to be a non-revenue generating feature. Interestingly, the company decided to relaunch co-viewing this year. I don’t have visibility anymore on how this is performing relative to revenue generated. Yet, as with anything, I wish them lots of success.
Always Be Learning
One of the reasons I moved on from Rakuten Viki earlier this year despite the high concentration of talent is that I stopped learning for too long. The reward for procrastination is the present and you pay with it with your future. Between 2016 and 2018 when Viki was at its peak in innovating, there was so much things to learn. It has now become too comfortable, especially after our main competitor DramaFever closed shop. With competition gone, complacency breeds. That said, if you’re in Singapore, Viki is still an excellent place to learn from. In Singapore, the only tech company supporting Android Instant App, Android TV, Chrome OS, Android Mobile, Tablet, and Amazon Fire TV is Viki. Moreover, as of writing, there are only three Android engineers working on all those platforms. That said, we have also reached a point where the metrics in our Android Vitals is much better than other video streaming services. For example, our app size remains the smallest among known video streaming providers. I have never worked with a team as good as them. So if you’re an Android engineer looking for a place to go, think about Viki.
I have to say that working on Android Instant App was one of the most fun time I had as a Software Engineer. It was new, it was crazy, but it was lots of fun. Today, the entire team at Viki who were involved with the original Android Instant App has since moved on. Yet, I’ll look back to that day time and again. It is certainly a feat worth remembering.
¹ This is largely thanks to the Product Team, especially to Alex Chan, and Lizzie Zhang, who were very much instrumental in partnering with the engineering team to get all these bottled up ideas out the door.
² By the way, I couldn’t post screenshots because I’m writing this long after I graduated from Rakuten Viki. I don’t have access to the source code anymore and am only writing based on my recollection.