2

I´ve been working on a android webkit application, which has a considerably sophisticated UI (plenty of icons, CSS, JS and HTML5 pages). However, the application drains device battery. I installed some tools to measure power consumption and it´s pretty clear that the Android webkit (not the application engine) really demands CPU to render HTML content and it also impacts on battery consumption (oh! and memory as well). I´d like to know if anyone has ever had any problem with webkit vs. performance (power and CPU consumption). In addition, is there any Android webkit component (instead of WebView) with better performance?

--Raul

s9rlherb
  • 68
  • 1
  • 7
  • Not only does it drain a lot while in use, but I'm finding on my Samsung Note 8 that the webviews leak as well and continue to drain long term as long as your app is running. I may need to run them in a separate process and kill that process to resolve it (my app runs in the background for a long time). – CamHart Jul 12 '20 at 11:04

2 Answers2

1

I do find that the browser does consume a high amount of CPU but only during rendering. Once the page is loaded usage drops to 0.00%.

Have you run top on the device and made sure this is where the CPU usage is coming from?

Kevin Parker
  • 16,975
  • 20
  • 76
  • 105
1

It's very smart to optimize whatever your WebView loads to be friendly. A mobile device is not a small laptop. If your JavaScript, especially with a framework like jQuery, does a lot of animations, fade effects or if you keep pinging with asynchronous connections, your device will drain battery.

If you need to use WebView extensively, make sure to balance JavaScript actions (which use CPU) based on user activity (if user is active, have the actions running more often, if not, then don't keep certain actions in a loop). It's also smart to optimize your CSS and web in general so that least amount of processing power is required to load the page. Even compressing your Javascript, CSS and returned HTML is a good way to go about it.

kingmaple
  • 4,200
  • 5
  • 32
  • 44