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.

1
  • Same issue facing! Any solution for Phonegap build?
    – byJeevan
    Jun 23, 2014 at 17:18

4 Answers 4

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.

0
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);
2
  • Is there any tag to add this/ these
    – Lekhnath
    Sep 6, 2013 at 10:57
  • 1
    <application android:hardwareAccelerated="true" did indeed fix the sluggish scrolling issue for me
    – jwinn
    Oct 25, 2013 at 6:09
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.

2
  • This solved some of my render issues and sped up my app. Weird.
    – TWilly
    Feb 14, 2014 at 20:46
  • can you give more details please Sep 12, 2014 at 12:26
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.