Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap - Bad Performance compared to Browser on Android

I developed an application for android using jquery mobile and phonegap. I deployed the app to my device over usb. The performance of the app ist really bad, especially while scrolling a longer list.

The strange thing is: The whole app runs smooth if i just open up the browser on my phone and access the index.html directly. Same technology, same content. I do not use the phonegap native api or anything similar.

Tested with phonegap 1.5.0 and 1.7.0rc1, jquery mobile 1.1.0 on android 4.0.2.

Any ideas?

like image 606
rbk Avatar asked Apr 28 '12 15:04

rbk


3 Answers

On honeycomb (3.0), Ice cream (4.0) and posterior devices, you can boost performance by adding the following in the < Application ... > tag:

android:hardwareAccelerated="true"

You could set the minSdk to 8 (Android 2.2) for compatibility and the targetSdk to 15 (Android 4.0) and that would make hardware acceleration work when its available on the device only.

I believe that with this flag the performance of my apps is equal to running them in the browser, so I guess its because the browser was coded with hardware acceleration :)

like image 77
alfongj Avatar answered Nov 17 '22 10:11

alfongj


I had a similar problem: a page with a longer list of "medium complex" themed divs. The browser of HTC phone had no problems in displaying. But within the phonegap app rendering failed completely. I saw a kind of WSOD, which disappeared only after touching the display. After touching, the page was displayed correct.

The problem was not in place, when I shortened the div-list to one or two div-elements or when I reduced the sub elements within the divs and reduced the render effort caused by the css complexity.

The white screen looked like, if the whole body was invisible, since only the documents background-color was displayed (I added a light pink for this). So I guess, the rendering was the problem after reading this thread

I tried the various proposals I found in this thread to make the app work without the "WSOD". But nothing worked. Some of them made the app displaying really worse.

Finally, after a whole day of searching, I made it. I set within the tag (not the tag) of my AndroidManifest

<application android:hardwareAccelerated="false" ...

Now the app behaves in the same fast way as my webbrowser. Seems like, if hardware acceleration is not always the best feature...

My versions: phonegap 3.5.0, Android 4.0.3, jQuery v2.1.0, HTC Sense 3.6

like image 43
user3595386 Avatar answered Nov 17 '22 12:11

user3595386


Found an answer here: http://groups.google.com/group/phonegap/browse_thread/thread/94da1cf881abe995/6d4f7aea7aeba523?lnk=gst&q=performance

There is probably a difference between the native browser and the webview in terms of javascript performance.

like image 1
rbk Avatar answered Nov 17 '22 10:11

rbk