Poplayer: A Solution for Separating Temporary and Stable Business in Mobile Apps
NetEase Cloud Music’s Poplayer adds a WebView overlay to Android apps, isolating temporary features from core functionality while enabling hot‑swappable, reusable modules, and achieves massive memory savings—over 80,000‑fold—and up to 90‑times faster drawing through position/alpha caching, bitmap size reduction, clipRect drawing, and ARGB‑to‑ALPHA_8 optimization.
This article introduces Poplayer, a solution developed by NetEase Cloud Music for handling temporary business (like easter eggs and special features) separately from stable core business in Android applications.
Background: The team faced challenges with various special scenarios requiring temporary features that couldn't be reused and added complexity to stable playback functionality. They needed a solution that is configurable, reusable, real-time, and dynamic.
What is Poplayer: Poplayer (Pop + Layer) adds an overlay layer on top of the client page, implemented using WebView. It handles temporary business through this separate layer while keeping the stable business unaffected. The two layers communicate via JSBridge, achieving hot-swappable and reusable temporary features.
Memory Optimization: The article details several optimization techniques:
1. Position and Alpha Caching: Using AlphaCache to store previous click positions and alpha values, avoiding redundant calculations. This reduces memory allocation and drawing operations by 2 times each, improving performance by 4 times.
2. Bitmap Size Optimization: Instead of capturing the entire WebView (1080×2248), they reduced bitmap to 10×10 pixels while using canvas translation to capture only the relevant area. Memory usage reduced by over 20,000 times.
3. Partial Drawing with clipRect: Using canvas.clipRect() to draw only a small portion. Drawing in a 100×100 Rect takes only 9ms, and 10×10 takes 1ms - a 90x speed improvement.
4. Bitmap Config Optimization: Switching from ARGB_8888 to ALPHA_8 (since only alpha value is needed), reducing memory to one-fourth.
Overall optimization achieved: over 80,000x memory reduction and 90x drawing time reduction.
WebView Enhancement: Handling the MissingWebViewPackageException by wrapping Poplayer in a Fragment and using runCatching to gracefully handle failures.
Future Improvements: Consider using ReactNative or Flutter containers instead of HTML5 for better performance and stability.
NetEase Cloud Music Tech Team
Official account of NetEase Cloud Music Tech Team
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.