Error HCaptchaWebView not displayed
qiusanxin opened this issue · 5 comments
Initialize Hcaptch with different fragmentActivity, webview is abnormal when hcaptch is displayed
HCaptcha.getClient(fragmentActivity)?.setup(hCaptchaConfig())?.verifyWithHCaptcha()
The first call shows success, the second call fails
Error log
HCaptchaWebView not displayed because it is too large to fit into a software layer (or drawing cache), needs 10467840 bytes, only 10368000 available HCaptchaWebView not displayed because it is too large to fit into a software layer (or drawing cache), needs 10467840 bytes, only 10368000 available
I tried removing
HCaptchaWebViewHelper#setupWebView() //webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
this problem can be solved
@qiusanxin thanks for reporting the issue.
Could you please confirm that webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
removing fixes the issue for you?
Could you please share more details on the conditions when it happens (Android OS version, device model etc.)
After I remove webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null), the problem is solved,
Android 13 version of Mi 10Ultra
But I did not reproduce this problem on OPPO or OnePlus devices
@DSergiu I think we have several options here:
- Implement some
OnWebViewConfigurer
interface which will allow the end users to configureWebView
i.e. disableLAYER_TYPE_SOFTWARE
and set https://developer.android.com/reference/android/view/View#LAYER_TYPE_NONE for example - We may add an explicit flag to
HCaptchaConfig
something likeHCaptchaConfig.softwareLayerType
which will betrue
buy default - We may remove the line https://github.com/hCaptcha/hcaptcha-android-sdk/blob/main/sdk/src/main/java/com/hcaptcha/sdk/HCaptchaWebViewHelper.java#L88 at our own risk. I have tested on the recent Android OSes there are no issues, but they may be on older one because per docs:
.... If a view that is hardware accelerated (for instance, if your whole application is hardware acclerated), is having rendering problems, this is an easy way to work around limitations of the hardware rendering pipeline.
There are no notes about what kind of issues may be in this article, probably something like this https://stackoverflow.com/questions/20675554/webview-rendering-issue-in-android-kitkat
In my opinion, the first approach is more flexible (we provide a similar API on iOS)
After some additional research:
- There is a problem with enabling back hardware acceleration, per documentation
.... You currently cannot enable hardware acceleration at the view level. View layers have other functions besides disabling hardware acceleration.
So once we disabled it there is no reliable way to enable it back - Looks better choice at the moment
- Removing this line may lead to unwanted UI artifacts
HCaptchaConfig.disableHardwareAcceleration
now allow to configure this behavior