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

NSInvalidArgumentException: -[RNCWebViewImpl destroyWebView]: unrecognized selector sent to instance 0x10b1e9a00 #3298

Closed
salisuabubakar opened this issue Jan 22, 2024 · 12 comments
Labels

Comments

@salisuabubakar
Copy link

Hello,
i get this error when i navigate back from the webview screen

"""""""""""""""
NSInvalidArgumentException: -[RNCWebViewImpl destroyWebView]: unrecognized selector sent to instance 0x10b1e9a00
"""""""""""""""

The app crashes automatically. Thanks

@chriszs
Copy link

chriszs commented Jan 26, 2024

OS: iOS Simulator on MacOS
OS version: iOS Simulator 17.2 on Sonoma 14.2.1
Xcode version: Version 15.1 (15C65)
react-native version: 0.73.2
react-native-webview version: 13.6.4

Full error:

[CoreFoundation] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RNCWebViewImpl destroyWebView]: unrecognized
selector sent to instance 0x11d38d400'
*** First throw call stack:
(
0   CoreFoundation                      0x0000000180491128 __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x000000018008412c objc_exception_throw + 56
2   CoreFoundation                      0x00000001804a5f78 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3   UIKitCore                           0x000000018531b6e0 -[UIResponder doesNotRecognizeSelector:] + 232
4   STAT                                0x0000000101f82dec -[RNCWebViewImpl forwardInvocation:] + 220
5   CoreFoundation                      0x0000000180495054 ___forwarding___ + 732
6   CoreFoundation                      0x000000018049759c _CF_forwarding_prep_0 + 92
7   STAT                                0x0000000101f6a500 -[RNCWebView prepareForRecycle] + 80
8   STAT                                <…>

Encountered on an Expo Prebuild (aka bare/ejected) app when navigating away from a stack screen with the webview, as rendered by react-native-autoheight-webview (1.6.5) right after turning on the new architecture to test that in the app.

Can provide a minimal repro if wanted.

@isinuyk
Copy link

isinuyk commented Jan 26, 2024

+1
For me, it is IOS only when the new arch is turned on
I have
react-native: 0.73.2
react-native-webview: 13.6.4
react-native-screens: 3.29.0
@react-navigation/native: 6.1.9
@react-navigation/native-stack: 6.9.17

So, the crash happens when I navigate away from WebView screen, it can be either navigation.goBack(), or just using the swipe to the right gesture on IOS.
FYI, I was able to fix it by downgrading the react-native-webview to 13.6.3 BUT in that case pod install(with new arch) were failing and I had to add the following command to my profile post-install script:

    installer.pods_project.targets.each do |target|
      if target.name === "react-native-webview"
        append_header_search_path(target, "${PODS_ROOT}/Headers/Private/Yoga")
      end
    end

and define this append_header_search_path function globally on the top of podfile

def append_header_search_path(target, path)
  target.build_configurations.each do |config|
      # Note that there's a space character after `$(inherited)`.
      config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) "
      config.build_settings["HEADER_SEARCH_PATHS"] << path
  end
end

and that's it. it fixes this crash for me.

@sonicbaume
Copy link

Same problem for me - when you navigate to a previous screen it crashes. Happens only on iOS with new architecture enabled.

My stack is:
@react-navigation/native: 6.1.7
@react-navigation/native-stack: 6.9.13
react-native-in-app-review: "4.3.3
react-native-screens: 3.29.0
react-native-webview: 13.7.0

Unfortunately I couldn't get 13.6.3 to install with the above fix.

@isinuyk
Copy link

isinuyk commented Feb 1, 2024

Same problem for me - when you navigate to a previous screen it crashes. Happens only on iOS with new architecture enabled.

My stack is: @react-navigation/native: 6.1.7 @react-navigation/native-stack: 6.9.13 react-native-in-app-review: "4.3.3 react-native-screens: 3.29.0 react-native-webview: 13.7.0

Unfortunately I couldn't get 13.6.3 to install with the above fix.

what is the RN version you have? and did you get the error during pod install or the build phase?

@sonicbaume
Copy link

Woops! I'm using RN 0.73.2. When I use react-native-webview 13.6.3 then pod install is fine, but it fails to build.

@sudheerkarumanchi
Copy link

All, facing similar issue
tried above pod file changes but it still app crashes.
Do we have any alternate approach here? Please suggest. It works good in simulator but fails badly in both iPhone/iPad.

@RalissonMattias
Copy link

RalissonMattias commented Feb 5, 2024

I'm getting this issue. In my simulator works fine, but in testflight version the application breaks when the component is unmounting. The new arch is enabled

@cipolleschi
Copy link

Hi there! I'm Riccardo, from the React Native core team.

Thank you so much for raising this issue. The problem should not be addressed in WebView as this issue revealed a broader problem in React Native Core.
We are going to fix it there with this pr.
Main is already fixed.

@sonicbaume
Copy link

RN 0.73.5 fixed this for me. Thanks @cipolleschi 😄

@farwayer
Copy link

unfortunately, this fix has not yet been ported to the 0.72 yet 😢

@cipolleschi
Copy link

My bad... I forgot to request the pick for 0.72. :(

I created a PR facebook/react-native#43240 against 0.72, hopefully still in time to be merged before the release...

Copy link

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

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

Successfully merging a pull request may close this issue.

7 participants