Open ViktorOsadchyi opened 2 years ago
same issue, please check it
@ViktorOsadchyi
Will style={{ opacity: 0.99 }}
fix the emptiness issue?
And if this issue can also reproduce with react-native-webview ?
FYI: https://github.com/react-native-webview/react-native-webview/issues/1915
@iou90 I used style={{ opacity: 0.99 }} and it didn't work for me. I think the problem is that I am using a webview with high height content inside a flatlist
I have never been able to find a solution to this problem with this library. I tried using react-native-webview and it worked for me, however I had to calculate the height of the webview content myself
@ViktorOsadchyi
I can not reproduce this issue with:
OS version: Android 12 emulator
react-native version: 0.69.1
react-native-webview version: 11.22.7
react-native-autoheight-webview version: 1.6.4
Can you test with the same conditions as above?
Just a heads up. I'm seeing the same issue on Android, although we're using https://github.com/formidable-webview/webshell for autoheight, which works similar to this library.
The issue is most likely upstream in react-native-webview.
I see this in Flipper which may be relevant:
Possibly related: https://stackoverflow.com/questions/62080137/android-webview-does-not-display-web-page-even-though-the-page-has-successfully
I solved my problem using the react-native-webview library, on which react-native-autoheight-webview is built However, I had to write my own script to calculate the height and embed it in injectedJavaScript
It seems that this solved the problem and now the content is always displayed.
@ViktorOsadchyi this issue may not always reproduce. It's possible something you're doing makes it less likely to occur, but it will still occur in other cases. I'm doing some manual height adjustments as well and not using this library, and I have a case where I can always trigger this bug.
i fixed this with removeClippedSubviews={false} on flatlist, and overflow: 'hidden' on the webview style
DON'T USE THIS LIBRARY.
Lib can be replaced by WebView injectedJavaScript.
const webViewScript = `
setTimeout(function() {
window.ReactNativeWebView.postMessage(document.documentElement.scrollHeight);
}, 300);
true; // note: this is required, or you'll sometimes get silent failures
`;
<WebView
style={ {height}}
originWhitelist={['*']}
source={{
html,
}}
onMessage={(event) => {
console.log('event : ', event);
setHeight(parseInt(event.nativeEvent.data));
}}
scrollEnabled
injectedJavaScript={webViewScript}
javaScriptEnabled
/>
It automatically adjusts to fit the HTML content height.
For more information, please refer to the following. https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#communicating-between-js-and-native
@choijiho0021
Your comment did not work either. It does do SOMETHING but it is not accurate at all. It's not your fault, but the height value is wrong.
@choijiho0021 this worked like a charm
Bug description: We use multiple webview components on one screen along with native listings in flatlist. On iOS, there are no problems with display and performance. However, on Android, we encountered a crash when displaying several webview components. This issue was fixed by adding
renderToHardwareTextureAndroid
,androidHardwareAccelerationDisabled
andstyle={{ opacity: 0.99 }}
We also noticed that large content is no longer displayed if the webview component is inside a flatlist If you use androidHardwareAccelerationDisabled={false}, the content is sometimes displayed, but the behavior gets even weirder because sometimes the content still disappears. At the same time, the height of the component is correctly calculated and the scrollbar looks correct, but instead of content, there is emptiness
Source:
Screenshots/Videos:
Environment: