Does anybody have any insight about why I'm getting this warning in LogCat?
01-18 01:18:17.475: W/HardwareRenderer(25992): Attempting to initialize hardware acceleration outside of the main thread, aborting
I do this with my WebView in my Main activity (the main thread):
wv = (WebView) findViewById(R.id.main_webview);
wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
and I have this in my manifest:
<activity
android:name=".Main"
android:hardwareAccelerated="true"
android:label="@string/title_activity_main" >
Hardware layers can deliver faster and smoother animations when your application is hardware accelerated. Running an animation at 60 frames per second is not always possible when animating complex views that issue a lot of drawing operations.
What is Tethering Hardware Acceleration? Tethering hardware acceleration refers to the transfer of tethering traffic onto hardware via a direct path between the modem and peripherals in order to improve a device's performance and decrease power consumption.
Go back to Settings, scroll down and you should be able to see a new option called Developer options. Tap on it. Scroll down to the Hardware accelerated rendering and enable the toggle next to Force GPU rendering.
Here is how the Hardware Acceleration works in Android:
private void enableHardwareAcceleration(WindowManager.LayoutParams attrs) {
mAttachInfo.mHardwareAccelerated = false;
mAttachInfo.mHardwareAccelerationRequested = false;
// Don't enable hardware acceleration when the application is in compatibility mode
if (mTranslator != null) return;
// Try to enable hardware acceleration if requested
final boolean hardwareAccelerated =
(attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
if (hardwareAccelerated) {
if (!HardwareRenderer.isAvailable()) {
return;
}
// Persistent processes (including the system) should not do
// accelerated rendering on low-end devices. In that case,
// sRendererDisabled will be set. In addition, the system process
// itself should never do accelerated rendering. In that case, both
// sRendererDisabled and sSystemRendererDisabled are set. When
// sSystemRendererDisabled is set, PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED
// can be used by code on the system process to escape that and enable
// HW accelerated drawing. (This is basically for the lock screen.)
final boolean fakeHwAccelerated = (attrs.privateFlags &
WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED) != 0;
final boolean forceHwAccelerated = (attrs.privateFlags &
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED) != 0;
if (!HardwareRenderer.sRendererDisabled || (HardwareRenderer.sSystemRendererDisabled
&& forceHwAccelerated)) {
// Don't enable hardware acceleration when we're not on the main thread
if (!HardwareRenderer.sSystemRendererDisabled
&& Looper.getMainLooper() != Looper.myLooper()) {
Log.w(HardwareRenderer.LOG_TAG, "Attempting to initialize hardware "
+ "acceleration outside of the main thread, aborting");
return;
}
final boolean translucent = attrs.format != PixelFormat.OPAQUE;
if (mAttachInfo.mHardwareRenderer != null) {
mAttachInfo.mHardwareRenderer.destroy(true);
}
mAttachInfo.mHardwareRenderer = HardwareRenderer.createGlRenderer(2, translucent);
mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareAccelerationRequested
= mAttachInfo.mHardwareRenderer != null;
} else if (fakeHwAccelerated) {
// The window had wanted to use hardware acceleration, but this
// is not allowed in its process. By setting this flag, it can
// still render as if it was accelerated. This is basically for
// the preview windows the window manager shows for launching
// applications, so they will look more like the app being launched.
mAttachInfo.mHardwareAccelerationRequested = true;
}
}
}
From there, you can see that the log you are getting is when the hardware acceleration is asked outside of the main thread (as the log says).
In your case, you have to get more deep in your code and see all the non main threads, which one is calling the hardware acceleration.
I can't help you without more details (some code etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With