RxSwift: Application crash sending `text` selector to RxTableViewDelegateProxy or RxCollectionViewDelegateProxy
Short description of the issue:
We’re seeing a crash among our userbase that is happening with alarming frequency however we have been unable to reproduce it or identify the root cause. A slack discussion was started here among 2 of us that are seeing this problem but we wanted to post here with the hopes that someone else may have an idea about something to look at.
This is the stack trace/crash:
-[RxCocoa.RxTableViewDelegateProxy text]: unrecognized selector sent to instance 0x28378a0d0
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x99288 __exceptionPreprocess
1 libobjc.A.dylib 0x16744 objc_exception_throw
2 CoreFoundation 0x176fc4 +[NSObject(NSObject) _copyDescription]
3 CoreFoundation 0x2de98 ___forwarding___
4 CoreFoundation 0x2cf70 _CF_forwarding_prep_0
5 ContextKitExtraction 0x59ec +[CKContextContentProviderUIScene _bestVisibleStringForView:usingExecutor:]
6 ContextKitExtraction 0x4d7c +[CKContextContentProviderUIScene _donateContentsOfWindow:usingExecutor:withOptions:]
7 ContextKitExtraction 0x48fc __78+[CKContextContentProviderUIScene extractFromScene:usingExecutor:withOptions:]_block_invoke
8 ContextKitExtraction 0x54ac __64-[CKContextExecutor addWorkItemToQueue:withWorkItem:andContext:]_block_invoke
9 libdispatch.dylib 0x1e6c _dispatch_call_block_and_release
10 libdispatch.dylib 0x3a30 _dispatch_client_callout
11 libdispatch.dylib 0x11fa4 _dispatch_main_queue_drain
12 libdispatch.dylib 0x11b98 _dispatch_main_queue_callback_4CF
13 CoreFoundation 0x51800 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
14 CoreFoundation 0xb704 __CFRunLoopRun
15 CoreFoundation 0x1ebc8 CFRunLoopRunSpecific
16 GraphicsServices 0x1374 GSEventRunModal
17 UIKitCore 0x514648 -[UIApplication _run]
18 UIKitCore 0x295d90 UIApplicationMain
19 <OurAppName> 0x2b144c main + 20 (main.swift:20)
20 ??? 0x106badce4 (Missing)
I have scoured our code to see if we were somehow sending a text selector to anything in a weird way, this is not the case. Our app is large and uses tables in many screens but I haven’t found any misuse of rx.tems
.
Here are the pertinent facts I’ve been able to collect about the problem:
- iOS 15.x.x only. We have users going back all the way to iOS 10.0 and no one experiences the crash other than iOS 15 users. We have a large user base so this shows up enough for us to have a large sample (thousands of crash events)
- SDK doesn’t matter. I have viewed crashes going back to before we upgraded to Xcode 13 (using Xcode 12). These users had the crash as well (running on iOS 15).
- The only API change of note in tables/collection views in iOS15 is the automatic prefetching which doesn’t involve code changes necessarily or invoke a text selector anywhere.
- The stack makes it clear that whatever the source is, it’s going through dynamic dispatch / objc_msgSend and being marshaled to the ui thread or called from the ui thread using dispatch.async as it unwinds the stack out to the runloop to invoke this invalid selector on the proxy.
This crash is alarming because it seems to only occur on iOS15. Users from previous versions of iOS do not exhibit this problem. We haven’t been able to determine if this is a bug in iOS, a bug in RxSwift or a bug in our usage of it. The os-specific nature of it makes me wonder if there’s an iOS bug or a bug in the RxSwift framework that just hasn’t come to light yet.
Any insights would be greatly appreciated.
Expected outcome:
No crashes
What actually happens:
Crash
Self contained code example that reproduces the issue:
I wish I had one or I’d be able to identify the problem 😦
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
RxSwift 6.2.0 - https://github.com/ReactiveX/RxSwift/commit/7c17a6ccca06b5c107cfa4284e634562ddaf5951
Platform/Environment
- iOS
- macOS
- tvOS
- watchOS
- playgrounds
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
About 3% of our userbase is experiencing this. This includes users of other versions of iOS however that do not experience the issue at all.
Xcode version:
Xcode 13.2.1(13C100) although as stated it seems Xcode 12.4 was used at the time this first started showing up but before we noticed it.
Installation method:
- CocoaPods
- Carthage
- Git submodules
I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)
- yes (which ones)
- no
Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)
- just starting
- I have a small code base
- I have a significant code base
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 41 (18 by maintainers)
Commits related to this issue
- Table/CollectionViewDelegateProxy crash workaround Implement crash workaround discussed here https://github.com/ReactiveX/RxSwift/issues/2428 until a more permanent solution is found — committed to SlashDevSlashGnoll/RxSwift by SlashDevSlashGnoll 2 years ago
- Table/CollectionViewDelegateProxy crash workaround Implement crash workaround discussed here https://github.com/ReactiveX/RxSwift/issues/2428 until a more permanent solution is found — committed to SlashDevSlashGnoll/RxSwift by SlashDevSlashGnoll 2 years ago
- Table/CollectionViewDelegateProxy crash workaround Implement crash workaround discussed here https://github.com/ReactiveX/RxSwift/issues/2428 until a more permanent solution is found — committed to ReactiveX/RxSwift by SlashDevSlashGnoll 2 years ago
- Table/CollectionViewDelegateProxy crash workaround Implement crash workaround discussed here https://github.com/ReactiveX/RxSwift/issues/2428 until a more permanent solution is found — committed to GalBerezansky/RxSwift by SlashDevSlashGnoll 2 years ago
@mkj-is we only have 3 days of it being live, but so far no crashes on the version with this patch in place in our app. I’ll update with any changes if more crashes happen with this patch in place.
We are experimenting with this patch. We don’t have conclusive results yet. I will update you when we do. But the root cause is still unknown.
Looking over the implementation of “DelegateProxy.swift” and “_RXDelegateProxy.m”, I’m not sure the logic is correct. In “DelegateProxy.swift”, “responds(to…” is checking super:
super.responds(to: aSelector)
But in “_RXDelegateProxy.m”, “forwardInvocation” is ignoring super.
The problem is that if the base class object also chooses to use object proxying, then the first check will return true (because the base class DOES respond to the selector) but the forwardInvocation call will fail with “selector not found”(since the message was never forward to “super”, which would have responded).
Hello @mkj-is , We’re having the exact same crash within our app, and today we were able to reproduce it. It seems like the crash is happening when the App is open and we try to use Siri
2022-06-07_23-03-54.9047_+0400-601c39d876053890e09ae677c7fd948089429656.crash.log
Small update: we found, that this stack trace appear much often on iOS 17.0.0 Afraid, that is may indicate some more serious issue with the app 😦
In our project, we not only added
text
property but also sent thenon-fatal
to Firebase about it. Also, 100% on iOS 17.0.0 of them are coming with flagbackground=true
in Firebase.@liweican1992 That is because
RACDelegateProxy
is not part of RxSwift, but seems like it is a part of some old ReactiveCocoa version. Using correct class name should fix.Since this bug is present in more FRP project I suspect this is indeed caused by some internal change in iOS.
Will we have a new release version of this workaround? Like
6.5.1
?PR opened! https://github.com/ReactiveX/RxSwift/pull/2445
As i see this MR is merged. May you say when new release will be?
Hey @SlashDevSlashGnoll @yan-zaitsev-hs - As I mentioned, I’d appreciate a quick PR with this “workaround”. For the time being it’s safe as far as I’m concerned.
It’s from Crashlytics there doesn’t seem to be a DL button so here’s a cleaned up copy/paste of the entire trace: