Why is PhoneGap slower than Browser?
Asked Answered
B

4

20

I'm running the same exact web app on Android under PhoneGap and under the built in Browser. The app runs fine on the built-in browser but is unbelievably slow under PhoneGap. Even basic scrolling on the page stutters under PhoneGap.

Is there anything, in general, that I might be doing wrong? I was under the impression that PhoneGap just uses the same WebKit renderer as the normal Browser app, so why would the same HTML and JavaScript run much slower inside PhoneGap?

P.S. This has been asked before, but due to wording I think the original question was misunderstood.

Branscum answered 28/8, 2012 at 20:5 Comment(1)
Same issue facing! Any solution for Phonegap build?Repudiation
B
15

I may have inadvertently stumbled on an answer to this. Turns out that the apps I was working on had android:targetSdkVersion in AndroidManifest.xml set to a really low value (i.e. my target Android version was something like 2.2). Increasing this to 14 (Android 4.0) appears to have hugely improved PhoneGap performance, at least on newer Android devices running ICS or Jelly Bean.

Setting a low targetSdkVersion seems to disable at least some of the performance improvements introduced in newer versions of Android.

So, if you want to see a big performance boost in PhoneGap, make sure your targetSdkVersion matches the max SDK version supported by the phone you're testing on.

Branscum answered 13/9, 2012 at 0:17 Comment(0)
D
7

I don't know phoneGap, but you can try these:

  • Adding android:hardwareAccelerated="true" in the manifest
  • If you use webview webview.getSettings().setRenderPriority(RenderPriority.HIGH); and webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
Dispensatory answered 28/8, 2012 at 20:42 Comment(2)
Is there any tag to add this/ theseAuschwitz
<application android:hardwareAccelerated="true" did indeed fix the sluggish scrolling issue for meSchonthal
J
2

It is counter-intuitive but you may actually need to turn off hardware acceleration for your webview. Hardware acceleration as of Android 4.0.4 does nothing for canvas and other redraw events, but actually removes CPU resources for those events.

Try adding this line of code in your app java file:

super.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Also set android:hardwareAccelerated="false" in the manifest.

Jehovah answered 6/12, 2013 at 3:30 Comment(2)
This solved some of my render issues and sped up my app. Weird.Catton
can you give more details pleaseKanpur
I
0

Same exact thing I experienced! Previously I was using Android 3.x for testing. As soon as I upgraded to 4.4.2 my Canvas was dead slow! Looking at the Rendering timeline I could see many Rasterization calls taking over 100ms and reducing my FPS to about 8! android:hardwareAccelerated="false" solved my issues. Is there a way to set hardwareAccelerated="true" depending on android version?

Isoleucine answered 19/2, 2015 at 19:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.