Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android / New Arch] injectJavaScript and presumably other commands get executed twice #3305

Open
birdofpreyru opened this issue Jan 28, 2024 · 6 comments · May be fixed by #3307
Open

[Android / New Arch] injectJavaScript and presumably other commands get executed twice #3305

birdofpreyru opened this issue Jan 28, 2024 · 6 comments · May be fixed by #3307

Comments

@birdofpreyru
Copy link

Bug description:

I found that injectJavaScript code gets executed twice on Android with the New Arch. It happens because once it gets executed here (as a consequence of that command processing pattern):

"injectJavaScript" -> webView.evaluateJavascriptWithFallback(args.getString(0))

then another time it gets executed here:

@Override
public void injectJavaScript(RNCWebViewWrapper view, String javascript) {
view.getWebView().evaluateJavascriptWithFallback(javascript);
}

I guess, similar error might be there with other actions handled via that commands pattern.

To Reproduce:

Expected behavior:

Screenshots/Videos:

Environment:

  • OS:
  • OS version:
  • react-native version:
  • react-native-webview version:
@birdofpreyru
Copy link
Author

@Titozzz was totally wrong here — of course all these methods get called directly with the new arch; and I see no reason why the shared implementation, as it is implemented, could shadow these.

// These will never be called because we use the shared impl for now
@Override
public void goBack(RNCWebViewWrapper view) {
view.getWebView().goBack();
}
@Override
public void goForward(RNCWebViewWrapper view) {
view.getWebView().goForward();
}
@Override
public void reload(RNCWebViewWrapper view) {
view.getWebView().reload();
}
@Override
public void stopLoading(RNCWebViewWrapper view) {
view.getWebView().stopLoading();
}
@Override
public void injectJavaScript(RNCWebViewWrapper view, String javascript) {
view.getWebView().evaluateJavascriptWithFallback(javascript);
}
@Override
public void requestFocus(RNCWebViewWrapper view) {

birdofpreyru added a commit to birdofpreyru/react-native-webview that referenced this issue Jan 28, 2024
@17Amir17
Copy link
Contributor

Just ran into this today

@birdofpreyru
Copy link
Author

@17Amir17 you may consider to temporarily depend on my fork of the library, https://www.npmjs.com/package/@dr.pogodin/react-native-webview, which has this one and a few other issues fixed, as my PRs into the upstream version are pending the merge for a while now.

@17Amir17
Copy link
Contributor

Unfortunately I use this library as a peer dependency, so I'll have work around this in my case :(

@Nantris
Copy link

Nantris commented Mar 7, 2024

Any progress on this? I see @birdofpreyru submitted a PR to fix this.

@kxc-waddlaw
Copy link

Any update? Still occurs in react-native-0.73.6 & react-native-webview-13.8.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants