pwnall / chromeview

Proof of concept Android WebView implementation based on Chromium code
1.69k stars 434 forks source link

Low FPS #20

Open ekelokorpi opened 10 years ago

ekelokorpi commented 10 years ago

12435932

I got ImpactJS HTML5 game engine running on OUYA game console with ChromeView, but only 12 fps.

Is there yet any solution for this?

pwnall commented 10 years ago

@ekelokorpi That's awesome news! :+1:

A new build of ChromeView might improve the performance. Sadly, there were some changes in the code that require me to change the building and packaging, so it might take a while to get a new build.

davisford commented 10 years ago

@ekelokorpi are you sure you're using hardware gpu acceleration?

ekelokorpi commented 10 years ago

@davisford how can i check that?

davisford commented 10 years ago

@ekelokorpi good question -- I'm fairly new to Android internals myself. I'm not 100% sure if there's something in settings that will tell you this. I do think you could resolve it via an API, though. For example, see this line in AwContents.java:

https://code.google.com/p/chromium/codesearch#chromium/src/android_webview/java/src/org/chromium/android_webview/AwContents.java&sq=package:chromium&type=cs&l=646

It calls the native function: canvas.isHardwareAccelerated(). I bet you could add a line of code to that file like:

Log.w(TAG, "Is hardware acceleration enabled? " + canvas.isHardwareAccelerated());  

And you should have your answer. I'm sure there's probably a better way to deduce this, but I don't know right now without spending more time with the platform. I know in the emulator, you can choose to explicitly turn this on/off, but not sure how to enable / disable on real hardware.

More info from the Android docs

ekelokorpi commented 10 years ago

Hmm i tried that and it returns false. So it's not using hardware acceleration.

Any idea how to fix it?

edit: i got it on by adding android:hardwareAccelerated="true" to manifest, but it's still 10 fps :(

geleto commented 10 years ago

I tried with a newer (August 6) build of Chrome as pwnall suggested, which can be found here: https://github.com/davisford/chromeview But this did not help

It seems that the accelerated canvas is disabled by default: https://code.google.com/p/chromium/codesearch#chromium/src/webkit/common/webpreferences.cc&q=accelerated_2d_canvas_enabled%20&sq=package:chromium&l=70&type=cs

Search the sources for accelerated_2d_canvas_enabled , setAccelerated2dCanvasEnabled . Is there a way to set this without recompiling webkit?

Edit: also found this: https://code.google.com/p/chromium/codesearch#chromium/src/android_webview/lib/main/aw_main_delegate.cc&q=kDisableAccelerated2dCanvas&sq=package:chromium&type=cs&l=65