Back to Blog

Engineering the Living Room Web: Deep Dive into My Time Building Amazon Silk for Fire TV (2015-2018)

5 min read Mohit Bhalla
Amazon Android FireTV Career Engineering
Engineering the Living Room Web: Deep Dive into My Time Building Amazon Silk for Fire TV (2015-2018)

Between 2015 and 2018, I had the incredible opportunity to serve as the Lead Mobile Developer for the Amazon Silk browser on the Fire TV platform. Building a web browser for a television presents a completely unique set of user experience, memory, and architectural challenges compared to standard mobile apps. Furthermore, because Silk is deeply embedded in the vast Google Chromium codebase, we had to constantly balance Amazon’s custom UI needs with complex upstream Chromium integrations.

Here is a detailed deep dive into the major architectural challenges, performance optimizations, and advanced Android design patterns I tackled during my years on the Silk team.

The Virtual Cursor (v2.0): A Game-Like Approach to TV Navigation

One of my proudest early achievements was designing the first iteration of the Silk Home Menu and a novel navigation control scheme from the ground up. Initially, controlling a web browser with a standard TV D-pad remote was janky; using constant speed was too slow, and relying on actual screen coordinates meant the cursor speed varied with the main thread’s latency.

Competing against and beating implementations from L6 SDEs, I took a step back and applied a design pattern typically used for smooth graphical output in games. I created a floating overlay that only activated when the Activity was in a resumed state, using heuristics to estimate where the cursor was going. Instead of relying on the main UI thread, I drew the cursor asynchronously using the Android Animation framework. To solve the accuracy versus speed problem, I built in dynamic speed multipliers, similar to mouse cursor acceleration curves. This approach delivered a consistent 30-60fps drawing update with minimal latency, turning the Virtual Cursor into a major differentiating component of Silk on Fire TV.

Bridging Frameworks, Removing Dependencies, and App-Wide Theming

Because Silk is based on Chromium, our UI resources were constantly changing during upstream merges, as Chromium defaulted to a light color theme while Silk utilized a dark theme. Developers were using a fragile per-resource override model that caused “up-leveling pain” where every upstream merge could delay releases.

I completely refactored this architecture into an app-wide style hierarchy. By utilizing ContextThemeWrapper, I created a clean inheritance structure that bridged two conflicting UI frameworks—Google’s and Amazon’s—without operational pain. Crucially, this refactor allowed us to drop expensive legacy dependencies like the Fluid library. This resulted in a massive decrease in our “DEX count” (the number of bytecode-level objects in the APK), significantly optimizing our application size. This stable UI hierarchy successfully paved the way for implementing Silk’s highly requested “Dark Mode” feature.

Slaying Silk’s #1 Memory Issue: JVM Internals and Garbage Collection

When I joined the team, problems with garbage collection were Silk’s #1 memory issue, frequently leading to unnecessary low-memory kills on constrained TV hardware.

Diving deep into the Java Virtual Machine internals, I identified that a widely mis-used “Singleton” design pattern was holding strong references to objects and severely hampering the garbage collector. I completely redesigned this underlying code—which had been originally written by a senior SDE III—by removing the strong references and replacing the Singleton with a Dependency Injection pattern. By passing objects as parameters rather than holding them in memory globally, we eliminated the object leaks and made the entire codebase vastly more testable.

Enabling Multi-Dexing for Fire TV

To build the Silk Home Menu, we wanted to utilize the FireOS Leanback Library to avoid re-implementing complex UI code from scratch, and we needed to support the new Ivy release Launcher. However, adding this dependency blew past Android’s technical build limits, causing our single-release binary to fail.

I drove the major architectural decision to enable Multi-Dexing specifically for Fire TV. This was a major application architecture change that required convincing senior engineers to ship different binaries across different device targets. I further optimized these new binaries using Proguard—a step that even upstream Chromium wasn’t doing—and designed a mitigation plan to prevent any app start-up regressions caused by loading multiple DEX segments into memory.

Intent Handling for ChromePublic on FireOS

Chromium’s ChromePublic default intent handling expected the platform to be standard Android, utilizing API bindings from Google Play Services. Because FireOS does not have Google Play Services, Silk’s intent handling behavior would completely break when absorbing upstream Chromium code.

I implemented an Intent Handling Interception architecture utilizing a proxy abstraction and a decorator design pattern. The decorator pattern allowed us to access package-level methods within the Chromium codebase directly, without modifying the Chromium source code itself, thereby minimizing future operational burden. The proxy pattern allowed Silk to pre-process incoming intents and determine if they were FireOS specific, seamlessly bridging Chromium’s logic with FireOS deep links.

Operational Excellence: Tooling, Testing, and Dashboards

Beyond application architecture, I focused heavily on the operational health and developer experience of the Silk team:

  • Static Analysis (FindBugs): After discovering via a COE that a crash in the v47 Silk Downloads UI could have been prevented, I integrated the FindBugs static analysis tool into our continuous build system, creating strict build-breakers for new violations to ensure we stopped shipping preventable UI crashes.

  • Eradicating Flaky Tests: I identified that dozens of our tests were falsely reporting because they were asserting UI components on the wrong thread (the instrumentation thread instead of the UI thread). I refactored the AmazonCriteriaHelper, fixing inherent flakiness across more than 65 instrumentation test suites down to zero.

  • Automated Metrics Dashboards: To catch regressions in binary size, I updated the Forge Builder to emit APK size and Dex count metrics, tying them to monitor portal alarms that would automatically cut SEV-3 tickets to the on-call engineer. I also replicated the CI build publishing to KOTA for the Fire TV APK, automating a manual deployment process and saving 30 minutes to an hour of developer time per release.

  • Modernizing Developer Tooling: Many developers on the team were still using legacy text editors like Eclipse, Vim, or Emacs. I actively mentored the team to migrate to IntelliJ and Android Studio, training them on crucial profiling tools like DDMS, HierarchyViewer, and the Layout Inspector to improve overall productivity and code quality.

Conclusion

My three years on the Silk team were a masterclass in Android performance, deep diving into complex open-source codebases, and insisting on the highest engineering standards. By focusing on the long-term architecture of the application, I was able to help transform Silk into a highly performant, stable, and engaging web experience for the living room.


What questions do you have about building browser technology for constrained TV hardware? Let’s connect on LinkedIn.

Comments