FloatingPanel icon indicating copy to clipboard operation
FloatingPanel copied to clipboard

Crash due to the use of method swizzling

Open nalexn opened this issue 2 years ago • 7 comments

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)?

  • Add as child view controllers

How many panels do you displays?

  • 1

Environment

Library version

1.7.6

Installation method

SPM

iOS version(s)

iOS 16.4

Xcode version

14.3

nalexn avatar Apr 11 '23 08:04 nalexn

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.

scenee avatar Jul 01 '23 06:07 scenee

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

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

nihedr9 avatar Nov 23 '23 14:11 nihedr9

@nihedr9

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

scenee avatar Dec 01 '23 23:12 scenee

@scenee not using any special third party librairies with it

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

nihedr9 avatar Dec 04 '23 13:12 nihedr9

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 avatar Feb 03 '24 01:02 scenee

@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.

scenee avatar Feb 23 '24 01:02 scenee

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

nihedr9 avatar Feb 28 '24 13:02 nihedr9