Android WebView Hardware Rendering Weird Artifact Issue
Thanks to Delyan for solving the issue. How he told me to solve it was to add -webkit-transform: translate3d(0,0,0)
to all parts that move.
KUDOS DELYAN!
Hardware Acceleration stops working on new APIs
Tested on API 18:
Perform the check by posting a Runnable
to the WebView
:
WebView webView = (WebView) findViewById(R.id.webview_id);
// Shows: "Is hardware accelerated? false"
// Toast.makeText(YourActivity.this, "Is hardware accelerated? " +
// webView.isHardwareAccelerated(),
// Toast.LENGTH_LONG).show();
webView.post(new Runnable() {
@Override
public void run() {
Shows: "Is hardware accelerated? true"
Toast.makeText(YourActivity.this, "Is hardware accelerated? " +
webView.isHardwareAccelerated(),
Toast.LENGTH_LONG).show();
if (webView.isHardwareAccelerated()) {
// isAccelerated();
} else {
// isNotAccelerated();
}
}
});
From resource page on Hardware Acceleration:
Hardware acceleration is enabled by default if your Target API level
is >=14, but can also be explicitly enabled.
If the image you are displaying is still pixelated, try setting:
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
and see if pixelation of the image gets better.
Consider reading the resource page on Hardware Acceleration.
Android webview slow
It depends on the web application being loaded. Try some of the approaches below:
Set higher render priority (deprecated from API 18+):
webview.getSettings().setRenderPriority(RenderPriority.HIGH);
Enable/disable hardware acceleration:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// chromium, enable hardware acceleration
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
// older android version, disable hardware acceleration
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
Disable the cache (if you have problems with your content):
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
Slow page transitions on Android with hardware acceleration on
It seems like Ionic has made a lot of Android-related fixes that really improved performance. In addition, I've splitted my Android version into two versions: 4.4 and pre-4.4. Pre 4.4 is using cordova-android-chromeview which makes it so much faster. Even though it adds ~20 MB to the apk, it worths it.
Related Topics
CSS Reference to Phone's Emoji Font
Android/View/View$Onunhandledkeyeventlistener (Onmeasure Error)
How to Avoid Scientific Notation in Double
Get Meta Data of Image - Android
Input Elements on Android 4.X Can Not Be Styled When Focused
How to Integrate Samsung Gear Steps in Android Application
Shared Preferences Reset Data When App Is Force Closed or Device Is Restarted
Is Fcm (Firebase Cloud Messaging) Token for One Device or for One Account
How to Handle App Lifecycle with Flutter (On Android and iOS)
Getting a JSONexception: End of Input at Character 0
How to Highlight the Table Row on Click
Addoncompletelistener Not Called Offline with Cloud Firestore
Gridlayoutmanager - How to Auto Fit Columns
Call Recorder Not Working in Android 10 (Q)
Is There a Workaround for The Android Browser Bug with CSS-Position and Clickable Areas
Android: Support Multiple Screens
Activity.Finish() Called But Activity Stays Loaded in Memory
How to Set a Ripple Effect on Textview or Imageview on Android