scenee / FloatingPanel

A clean and easy-to-use floating panel UI component for iOS
MIT License
5.61k stars 509 forks source link

Crash due to the use of method swizzling #586

Open nalexn opened 1 year ago

nalexn commented 1 year ago

Description

We've recently started getting random crashes with the following stack:

Crashed: com.apple.main-thread
0   libobjc.A.dylib                0x2224 cache_getImp + 132
1   libobjc.A.dylib                0x1057c cache_t::shouldFlush(objc_selector*, void (*)()) const + 64
2   libobjc.A.dylib                0xc668 invocation function for block in flushCaches(objc_class*, char const*, bool (objc_class*) block_pointer) + 32
3   libobjc.A.dylib                0xd534 flushCaches(objc_class*, char const*, bool (objc_class*) block_pointer) + 296
4   libobjc.A.dylib                0x1c6b8 _method_setImplementation(objc_class*, method_t*, void (*)()) + 224
5   libobjc.A.dylib                0x19da4 method_setImplementation + 96
6   myapp                          0x5b97ec one-time initialization function for dismissSwizzling + 647 (FloatingPanelController.swift:647)
7   libdispatch.dylib              0x64094 _dispatch_client_callout + 16
8   libdispatch.dylib              0x34bf8 _dispatch_once_callout + 28
9   myapp                          0x5b6c98 FloatingPanelController.setUp() + 641 (FloatingPanelController.swift:641)
10  myapp                          0x5b9fa0 specialized FloatingPanelController.init(delegate:) + 4317159328 (<compiler-generated>:4317159328)
11  myapp                          0x5b6a68 FloatingPanelController.init(delegate:) + 4317145704 (<compiler-generated>:4317145704)

Expected behavior

No crash

Actual behavior

A random crash

Steps to reproduce

I believe we've started seeing this crash after adding other libraries that also do swizzling. While this is understandable for SDKs like analytics to do the swizzling, I believe the libraries like this should refrain from using it. Please explore less hacky alternatives.

How do you display panel(s)?

How many panels do you displays?

Environment

Library version

1.7.6

Installation method

SPM

iOS version(s)

iOS 16.4

Xcode version

14.3

scenee commented 1 year ago

In v2.6.3, the swizzling implementation has been updated for cases where it is used with the analysis library. I would like you to try the version and please give me a feedback.

nihedr9 commented 1 year ago

any update on this ? still having the problem in v2.8.0

Capture d’écran 2023-11-23 à 15 15 54

scenee commented 12 months ago

@nihedr9

Is it possible to let me know which libraries the above crashes occur when used with?

nihedr9 commented 11 months ago

@scenee not using any special third party librairies with it

Do you want me to create a PR with your commit bea2980

scenee commented 9 months ago

I'm sorry for the late reply. I've added the commit into the master as 0e0f773. It would be helpful to know if this resolved the crash issue.

scenee commented 9 months ago

@nalexn, @nihedr9

I've released a possible fix at 0e0f773 in v2.8.2. If you still encounter this issue, I'm glad for you to report it in this issue. I would continue to investigate it.

nihedr9 commented 9 months ago

hey @scenee We don't have the crash anymore. Thank you for your assistance 👍