Custom drawing on Canvas can affect your app's frame rate and battery life. Drawing complex shapes or many objects every frame may reduce smoothness below 60fps. Excessive overdraw or inefficient paint operations increase CPU and GPU load, causing higher battery use and possible UI lag.
Custom drawing (Canvas) in Android Kotlin - Build, Publish & Deploy
To keep your app smooth, draw only what changes each frame. Cache static parts in a bitmap to avoid redrawing them repeatedly. Use hardware acceleration and avoid expensive operations like creating new objects inside the onDraw() method. Profile your drawing with Android Studio GPU tools to find bottlenecks.
Custom drawing code itself is small and does not significantly increase app size. However, if you include large bitmap resources or complex vector assets for drawing, these can increase your APK or AAB size and slow startup. Optimize image sizes and use vector drawables when possible.
Android uses Canvas API for custom drawing, typically inside View.onDraw(). iOS uses Core Graphics with draw(_ rect: CGRect) in UIView subclasses. Both platforms support hardware acceleration but differ in APIs and lifecycle. Android requires careful invalidation calls to redraw, while iOS uses setNeedsDisplay(). Understanding these helps when porting custom drawing code.
Ensure your custom drawing does not cause excessive battery drain or app crashes, as these can lead to rejection. Follow Android's Material Design guidelines for visual consistency. Avoid drawing misleading or inappropriate content. Test on multiple devices to ensure performance and visual quality meet Google Play standards.
Likely your custom drawing code is doing heavy work on the main thread during startup, such as decoding large bitmaps or complex drawing without caching. This blocks UI rendering. To fix, move heavy processing off the main thread, cache drawings, and simplify the drawing logic.