JavaScript / HTML / CSS apps on Android devices are extremely slow

We make some javascript games. They work great on iPhone, iPad, and on the desktop. The biggest problem is Android devices. All the tablets we have with Honeycomb OS 3.x (Samsung Tab 10.1, Motorola Xoom, Acer Iconia, etc.) are extremely slow when JavaScript is executed and content is created. It's better on 2.x phones, but still far behind Apple devices ...

We tried to use the traditional approach with the div element , as well as HTML5 canvas , but even a simple example of a ball rebound is very slow (if you want to test it, access http://sie.mautilus.com/canvas ).

If we turn off the debugging menu on Android, turn on OpenGL Rendering, which is slightly better, but still not suitable for a wide audience, not to mention the fact that the average user will not do this ...

This makes a JavaScript-based user interface that is an event bit that is completely unsuitable for Android ...

How is it that a simple bouncing ball that worked in MS-DOS on my Intel 386 machine is unsuitable for high-performance tablets with dual-core 1 GHz Cortex-A9 processors?

See also there:
http://code.google.com/p/android/issues/detail?id=17353
http://groups.google.com/group/phonegap/browse_thread/thread/fc13b40165db8a00?pli=1a

Regards, Stan

+4
source share
1 answer

You are right that it is very slow on Android devices, I ran into the same problem and searched on the Internet. I only find people who agree with us.

I have done several things to speed up the process (although it is of poor quality). I also only checked on HTC Sensation and Samsung galaxy tab 10.1. I think you will need to use different settings for different phones.

  • set the screens so that my phone does not create a larger canvas, and then reduce it again.
  • enlarge the scene 2 times. This will reduce the pixels used by half, so you actually have less canvas stretched across the entire screen.
  • Do not use clearRect to clear the entire canvas and then redraw everything. In fact, removing clearRect from your bouncing ball example will show many improvements. Clear areas that are actually changing (bats and ball), and then redraw them will be enough.

On the side, I didn’t notice that Android 2 and 4 are faster than 3, but this is based on testing on only 3 devices, therefore not hard statistics.

I also read that using translate3d on the canvas will render the equipment if it is available, but I have not verified / confirmed this.

Some code that might help you:

<meta name="viewport" content="width=device-width, initial-scale=0.5, user-scalable=no"/> $(gameEl).css('-webkit-transform', 'scale3d(2, 2, 0) translate3d(0, 0, 0)'); $(gameEl).css('-webkit-transform-origin', '0 0'); 
+2
source

Source: https://habr.com/ru/post/1392878/


All Articles