react-native-webview / react-native-webview

React Native Cross-Platform WebView
https://github.com/react-native-community/discussions-and-proposals/pull/3
MIT License
6.31k stars 2.96k forks source link

Webview bridge maybe has some bug since v13.8.2 #3368

Closed musicode closed 2 months ago

musicode commented 2 months ago

First, I open a webview page, then I open a new webview page, when I close the new page, the bridge in the first page is not work.

v13.8.1 is ok, but v13.8.2 is not work.

os: android

guo-pf commented 2 months ago

you can try:
` const [resetOnMessage, setResetOnMessage] = useState(false);

useEffect(() => { const unsubscribe = navigation.addListener('focus', () => { if (Platform.OS === 'android'){ setResetOnMessage(!resetOnMessage); } }); return unsubscribe; }, []);

const handleMessage = (event: WebViewMessageEvent) => {

}; <WebView source={{ uri: initUrl}} ... ...
onMessage={resetOnMessage ? handleMessage : handleMessage} ... ... /> `

RalissonMattias commented 2 months ago

I face a similar problem, when I use Webview within Flatlist, only the last message is captured

andreialecu commented 2 months ago

Seems related to #3352 (/cc @Kudo 🫣)

Kudo commented 2 months ago

i'm sorry to introduce the regression. does it require multiple WebView or enough for single WebView? would be highly appreciated if someone could help to create a repro

andreialecu commented 2 months ago

I have not fully tested this, I was looking into recent changes, but my understanding is that this is what happens:

Looking at the changes in #3352 I'm not sure I understand the exact reason for switching the first parameter here to a constant: https://github.com/react-native-webview/react-native-webview/pull/3352#discussion_r1549718289

gavrichards commented 2 months ago

We use onShouldStartLoadWithRequest to load most webpages in a new screen in a stack, rather than in the same view. We've noticed that since 13.8.2 this no longer works on Android. RN 0.73.6. Would this issue be related to that? Rolling back to 13.8.1 fixes it.

farwayer commented 2 months ago

I can confirm the problem with onMessage starting from 13.8.2 (several WebViews if it's important)

ad-walker commented 2 months ago

We use onShouldStartLoadWithRequest to load most webpages in a new screen in a stack, rather than in the same view. We've noticed that since 13.8.2 this no longer works on Android. RN 0.73.6. Would this issue be related to that? Rolling back to 13.8.1 fixes it.

Running into the same issue, when logging this block it looks like the messagingModuleName equality check is failing on subsequent onShouldStartLoadWithRequest/onMessage invocations.

react-native-community-bot commented 2 months ago

:tada: This issue has been resolved in version 13.8.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: