Reputation: 81
I am using WebView
inside ScrollView, and it is giving IllegalStateException
on Samsung SM-J610F. It is working fine on the rest of the devices that I have tested this code on.
When I take out WebView
out of ScrollView
it works fine. But the problem is that I have other views below WebView and if I don't use ScrollView
, the user will not be able to see those view.
Font Cache (CPU):
Size: 103.02 kB
Glyph Count: 37
CPU Caches:
Shadows: 4.22 KB (2 entries)
GPU Caches:
Other:
Buffer Object: 63.00 KB (2 entries)
Image:
Texture: 1.81 MB (28 entries)
Texture( 1): 168840 Byte (count:8)
Texture( 2): 54288 Byte (count:1)
Texture( 3): 44100 Byte (count:1)
Texture( 4): 31684 Byte (count:6)
Texture( 5): 29580 Byte (count:1)
Texture( 6): 29568 Byte (count:1)
Texture( 7): 29232 Byte (count:3)
Texture( 8): 28896 Byte (count:1)
Texture( 9): 28560 Byte (count:1)
Texture(10): 11024 Byte (count:1)
.......
Scratch:
Texture: 512.00 KB (1 entry)
RenderTarget: 1.46 MB (14 entries)
Buffer Object: 96.03 KB (4 entries)
Other Caches:
Current / Maximum
VectorDrawableAtlas 0.00 kB / 0.00 KB (entries = 0)
Layers Total 0.00 KB (numLayers = 0)
Total GPU memory usage
JNI DETECTED ERROR IN APPLICATION: JNI CallObjectMethod called with pending exception java.lang.IllegalStateException: Unable to create layer for WebView, size 640x7040 max size 8192 color type 4 has context 1
......
Upvotes: 8
Views: 2744
Reputation: 10252
In my case the error was Unable to create layer for RNCWebViewManager$f, size 1080x9661 exceeds max size 8192
and triggered a crash on Android 8 Samsung and Huawei devices.
Removing the parent ScrollView was not an option in my case because that was really needed.
Limiting the webview height to 2720 (DeviceSupported(8192)/3) fixed the issue.
This was the only workaround I found to keep the hardwareAccelerated
true
I had also to pass overScrollMode={'never'}
as webview prop.
Upvotes: 0
Reputation: 2718
Remove the webview out of the scroll view and place it individually. Also all the other views present add them inside of the Scrollview. This way your webview will be stable also, the users will be able to scroll and refer the other views. Also, the webview should be declared and implemented properly:
wv = (WebView) findViewById(R.id.web_view);
wv.setInitialScale(1); //webview page matches the screen size.
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); //loads online website when no internet connection.
wv.loadUrl("https://prajwalwaingankar.wixsite.com/nivala");
As per the above code, all the views are above of the webview and the webview covers up the rest of the remaining screen size using method
.setInitialScale(1);
Upvotes: 1