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

Fix crash in MulticastDelegate caused by concurrent accesses #3361

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

laevandus
Copy link
Contributor

@laevandus laevandus commented Aug 6, 2024

🔗 Issue Links

Resolves PBE-5434

🎯 Goal

Make MulticastDelegate thread-safe

🛠 Implementation

We got a report of crashes in the MulticastDelegate what point at multi-threading issues..

Fatal Exception: NSGenericException
0  CoreFoundation                 0x83f20 __exceptionPreprocess
1  libobjc.A.dylib                0x16018 objc_exception_throw
2  CoreFoundation                 0x18220c -[__NSSingleObjectEnumerator init]
3  Foundation                     0x29284 -[NSConcreteHashTable countByEnumeratingWithState:objects:count:]
4  Foundation                     0x291f8 -[NSConcreteHashTable allObjects]
5  <Redacted>                      0x87dd44 specialized MulticastDelegate.mainDelegate.getter
6  <Redacted>                       0x87f570 specialized MulticastDelegate.invoke(_:)
7  <Redacted>                       0x914c60 specialized DelegateCallable.delegateCallback(_:) + 95 (DataController.swift:95)

🧪 Manual Testing Notes

Explain how this change can be tested manually, if applicable.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (docusaurus, tutorial, CMS)

@laevandus laevandus added the 🐞 Bug An issue or PR related to a bug label Aug 6, 2024
@laevandus laevandus requested a review from a team as a code owner August 6, 2024 10:04
@Stream-SDK-Bot
Copy link
Collaborator

SDK Size

title develop branch diff status
StreamChat 6.76MB 6.82MB 0.06MB 🟢
StreamChatUI 4.41MB 4.41MB 0.0MB 🟢

@Stream-SDK-Bot
Copy link
Collaborator

SDK Performance

target metric benchmark branch performance status
MessageList Hitches total duration 10 ms 5.01 ms 49.9% 🔼 🟢
Duration 2.6 s 2.56 s 1.54% 🔼 🟢
Hitch time ratio 4 ms per s 1.96 ms per s 51.0% 🔼 🟢
Frame rate 75 fps 78.27 fps 4.36% 🔼 🟢
Number of hitches 1 0.4 60.0% 🔼 🟢
ChannelList Hitches total duration 12.5 ms 11.68 ms 6.56% 🔼 🟢
Duration 2.6 s 2.55 s 1.92% 🔼 🟢
Hitch time ratio 5 ms per s 4.59 ms per s 8.2% 🔼 🟢
Frame rate 72 fps 74.3 fps 3.19% 🔼 🟢
Number of hitches 1.2 1.0 16.67% 🔼 🟢

Copy link
Member

@nuno-vieira nuno-vieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just added a question 👍

Sources/StreamChat/Utils/MulticastDelegate.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Utils/MulticastDelegate.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Utils/MulticastDelegate.swift Outdated Show resolved Hide resolved
Sources/StreamChat/Utils/MulticastDelegate.swift Outdated Show resolved Hide resolved
Copy link
Member

@nuno-vieira nuno-vieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ✅

@laevandus laevandus force-pushed the fix/multicast-delegate-multi-threading-crash branch from a28e508 to 4de88df Compare August 6, 2024 12:36
@Stream-SDK-Bot
Copy link
Collaborator

SDK Size

title develop branch diff status
StreamChat 6.76MB 6.79MB 0.03MB 🟢
StreamChatUI 4.41MB 4.41MB 0.0MB 🟢

Copy link

sonarqubecloud bot commented Aug 6, 2024

@laevandus laevandus merged commit c6bc553 into develop Aug 7, 2024
15 checks passed
@laevandus laevandus deleted the fix/multicast-delegate-multi-threading-crash branch August 7, 2024 05:50
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug An issue or PR related to a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants