Android Question webview slow but web browser fast

quique

Member
Licensed User
Longtime User
Hi there!

I am trying to embed a simple html5 game on an apk using basic4android webview.

It works, on my Oneplus One, just fine, every time I try it.

But when I try it on other phones, some older / slower / less ram phones, game runs slow (on some cases it is impossible to play or the game does not even finish to load).

Strange enough this also happens on some not so old phones: Moto X, it runs painfully slow, until I reset Android (cycle power) and then it works fast (resources are free again ?). Same with Samsung Galaxy 4 ...

When I try the same games through Chrome Browser, the work significantly better... Chrome browser asks for more resources to satisfy its task ?

Is there any way on basic4android to ramp up the memory and/or cpu priority available by my app ?

I suppose I can also check for 1 or 2 gb of ram and dual core or bigger / 1ghz or bigger processors. But then I was under the impression that html5 was way lighter than -say- old sluggish flash. But it seems that at the end of the day, Html5 is really using up resources.

Any thoughts or comments are more than welcome!


Quique
 
Last edited:

quique

Member
Licensed User
Longtime User

Thanks, RandomCoder for pointing me into the heap size trick. I did it, but it keeps running way more slow on basic4android webview than on Google Chrome. Same Android device, for testing purposes a Toshiba A100 (Android 4.04, 1 Core 1Ghz Tegra chipset, 1 Gb RAM) I am tinkering with it a bit more, If I solve this speed difference mistery, I will post the solution.

In the meantime I am all-eyes for any test - idea you people may want to propose :)

Quique
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Do you need to use the Webview and keep within the confines of your app or could you use an intent to load the native browser, or Chrome to run the game? I do this for video files because support for different CODEC's is very poor from one device to another. So for me it is easier to allow MX Player or whatever other media app is installed to play the video. Just a thought. ;)
 
Upvote 0

quique

Member
Licensed User
Longtime User
Try to add this line to the manifest editor:
B4X:
SetApplicationAttribute(android:hardwareAccelerated, "true")

Thanks Erel, I added that line into my manifest. When testing on slower (older) devices, for instance an Android 4.01 tablet with 1 core at 1.2 Ghz, all games are responsive, and work like 5% faster than without that attribute. But still ... they are awfully slow (unplayable).

RANDOMCODER:

I tried to launch an intent on the web browser ... but it just refuses to navigate into file/// ... I had no luck there :(

I am reaching into the conclusion that for html5 gaming purposes, I should think on Android Jellybean onwards, where the webview / html5 / java engine is optimized enough for the task.

Directly from: http://developer.android.com/about/versions/jelly-bean.html#android-41

Android Browser and WebView
In Android 4.1, the Android Browser and WebViews include these enhancements:

  • Better HTML5 video user experience, including touch-to-play/pause and smooth transition from inline to full screen mode.
  • Improved rendering speed and reduced memory usage for better scrolling and zooming performance.
  • Improved HTML5/CSS3/Canvas animation performance.
  • Improved text input.
  • Updated JavaScript Engine (V8) for better JavaScript performance.
  • Support for the updated HTML5 Media Capture specification (the "capture" attribute on input type=file elements).
 
Last edited:
Upvote 0

quique

Member
Licensed User
Longtime User
The weirdest thing: When I compile the same games for api level 16 with:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>

4 out of 6 games are unresponsive (under Android 5.02): They do not acknowledge my tapping into the START button.

I lower min and target sdk version into 15 and they work fine.

So if I try to make my app for Jelly Beans onwards, I get mostly unresponsive games. I am currently trying to make some sense out of it and fixing it. I will post any further advance. Meantime, I am all eyes for any suggestion :)
 
Upvote 0
Top