-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Description
- cocos2d-x version: 3.17
- devices test on: Samsung Galaxy S9, Samsung Galaxy S6
Hi, I noticed that when calling webView->setBackgroundTransparent()
the performance of the webview is trashed on android, easily noticeable when scrolling.
Upon further investigation I found the following code:
public static void setBackgroundTransparent(final int index) {
if(android.os.Build.VERSION.SDK_INT >10) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Cocos2dxWebView webView = webViews.get(index);
if (webView != null) {
webView.setBackgroundColor(Color.TRANSPARENT);
try {
Method method = webView.getClass().getMethod("setLayerType",int.class,Paint.class);
method.invoke(webView,WebView.LAYER_TYPE_SOFTWARE,null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
}
Setting the layer to software mode is the culprit, obviously, since the webview has to be rendered several times when scrolling. Commenting out the software layer code makes the webview run smoothly on both devices I tested.
I'm wondering why the layer is being set to software mode and if it's really necessary.
Metadata
Metadata
Assignees
Labels
No labels