# iOS always crashes when deleting a channel (SBDMessageDatabase)

**URL:** <https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621>\
**Category:** iOS\
**Created:** [July 12, 2021, 4:51pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621 "2021-07-12T16:51:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![finchat](https://avatars.discourse-cdn.com/v4/letter/f/c57346/32.png) [@finchat](https://community.sendbird.com/u/finchat)\
**Post date:** [July 12, 2021, 4:51pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/1 "2021-07-12T16:51:50Z")

</div>

Problem:  
The iOS app crashes whenever a channel is deleted regardless of whether it was deleted in the app or from the SendBird dashboard.

Steps to reproduce:

1. Initialize SBD with SBDMain.initWithApplicationId() and then connect with SBDMain.connect()
2. Fetch the user’s channels with SBDGroupChannelListQuery.loadNextPage()

Everything works as expected up to this point. I am fetching the channels I previously created perfectly fine.

1. Delete the channel either with the iOS sdk or on the dashboard. The app will now crash

Throw Call Stack:  
0 CoreFoundation 0x000000010fb2ffba \_\_exceptionPreprocess + 242  
1 libobjc.A.dylib 0x0000000119860ff5 objc\_exception\_throw + 48  
2 SendBirdSDK 0x00000001157700d3 +[SBDMessageDatabase removeAllMessagesWithChannelUrls:] + 514  
3 SendBirdSDK 0x000000011580d0ba -[SBDCommandProcessor processChannelDeleted:] + 357  
4 SendBirdSDK 0x000000011580b293 -[SBDCommandProcessor processSystemEvent:sender:] + 676  
5 SendBirdSDK 0x0000000115807294 -[SBDCommandProcessor processCommand:shouldHandleBlock:] + 511  
6 SendBirdSDK 0x000000011575bae5 \_\_103+[SBDMain connectWebSocketServerReconnect:userId:accessToken:sessionKey:fromOnError:completionHandler:]\_block\_invoke.423 + 197  
7 SendBirdSDK 0x00000001157f1399 -[SBDWebSocketClient webSocket:didReceiveMessage:] + 376  
8 SendBirdSDK 0x00000001157a3266 \_\_35-[SBDSessionWebSocketEngine listen]\_block\_invoke\_4 + 156  
9 libdispatch.dylib 0x000000011c321578 \_dispatch\_call\_block\_and\_release + 12  
10 libdispatch.dylib 0x000000011c32274e \_dispatch\_client\_callout + 8  
11 libdispatch.dylib 0x000000011c328f9a \_dispatch\_lane\_serial\_drain + 796  
12 libdispatch.dylib 0x000000011c329c67 \_dispatch\_lane\_invoke + 436  
13 libdispatch.dylib 0x000000011c335a7a \_dispatch\_workloop\_worker\_thread + 872  
14 libsystem\_pthread.dylib 0x000000011c7f545d \_pthread\_wqthread + 314  
15 libsystem\_pthread.dylib 0x000000011c7f442f start\_wqthread + 15

I believe the problem is in SBDMessageDatabase.removeAllMessagesWithChannelUrls()

The application is connected to the sendbird sdk through a websocket and when it tries to remove all the messages in the channel, the application crashes and throws the error: “Terminating app due to uncaught exception ‘Sendbird Exception’, reason: ‘Database error.’”

Please make an update to resolve this issue.

Thanks

---

<div class="post-metadata">

**Author:** ![Woo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/woo/32/125_2.png) [@Woo](https://community.sendbird.com/u/Woo)\
**Post date:** [July 12, 2021, 7:17pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/2 "2021-07-12T19:17:23Z")

</div>

@finchat could you tell me environment settings and version? thanks

---

<div class="post-metadata">

**Author:** ![finchat](https://avatars.discourse-cdn.com/v4/letter/f/c57346/32.png) [@finchat](https://community.sendbird.com/u/finchat)\
**Post date:** [July 12, 2021, 8:22pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/3 "2021-07-12T20:22:35Z")

</div>

Hi @Woo  
I’m using the latest version of SendBird - 3.0.227  
iOS Deployment Target - Tested with version 11.0 and 14.5  
Tested with iPhone 11 simulator and physical iPhone 11

Please let me know if you need more info

---

<div class="post-metadata">

**Author:** ![finchat](https://avatars.discourse-cdn.com/v4/letter/f/c57346/32.png) [@finchat](https://community.sendbird.com/u/finchat)\
**Post date:** [July 12, 2021, 10:56pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/4 "2021-07-12T22:56:10Z")

</div>

Hi @Woo  
I have more information:

SBDGroupChannel.sendUserMessage() is causing a crash as well. There is something very wrong with the database on the latest version.

I tried reverting back to version 3.0.216 and everything works as expected. I will be using this version for now.

---

<div class="post-metadata">

**Author:** ![Woo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/woo/32/125_2.png) [@Woo](https://community.sendbird.com/u/Woo)\
**Post date:** [July 12, 2021, 11:26pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/5 "2021-07-12T23:26:48Z")

</div>

local caching feature is included in latest version, I will check with exception handling. you can use 3.0.226

---

<div class="post-metadata">

**Author:** ![Woo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/woo/32/125_2.png) [@Woo](https://community.sendbird.com/u/Woo)\
**Post date:** [July 12, 2021, 11:27pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/6 "2021-07-12T23:27:19Z")

</div>

Do you mind to share the crash you experience on sendUsesrMessage too?

---

<div class="post-metadata">

**Author:** ![finchat](https://avatars.discourse-cdn.com/v4/letter/f/c57346/32.png) [@finchat](https://community.sendbird.com/u/finchat)\
**Post date:** [July 12, 2021, 11:43pm UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/7 "2021-07-12T23:43:23Z")

</div>

Yes, I can confirm 3.0.226 is working well.

Here’s the call stack for the crash:

2021-07-12 16:42:52.521997-0700 FinChat[13448:8276204] \*\*\* Terminating app due to uncaught exception ‘Sendbird Exception’, reason: ‘Database error.’  
\*\*\* First throw call stack:  
(  
0 CoreFoundation 0x000000010c6abfba \_\_exceptionPreprocess + 242  
1 libobjc.A.dylib 0x00000001162c1ff5 objc\_exception\_throw + 48  
2 SendBirdSDK 0x00000001121f32ea +[SBDGroupChannelDatabase insertOrReplaceWithChannels:] + 512  
3 SendBirdSDK 0x000000011222ea77 -[SBDChannelDataSource updateChannel:] + 173  
4 SendBirdSDK 0x0000000112261cbe \_\_48-[SBDCommandProcessor processNewMessage:sender:]\_block\_invoke\_2 + 166  
5 libdispatch.dylib 0x0000000118d82578 \_dispatch\_call\_block\_and\_release + 12  
6 libdispatch.dylib 0x0000000118d8374e \_dispatch\_client\_callout + 8  
7 libdispatch.dylib 0x0000000118d91b3f \_dispatch\_main\_queue\_callback\_4CF + 1152  
8 CoreFoundation 0x000000010c6198f8 **CFRUNLOOP\_IS\_SERVICING\_THE\_MAIN\_DISPATCH\_QUEUE** + 9  
9 CoreFoundation 0x000000010c614169 \_\_CFRunLoopRun + 2781  
10 CoreFoundation 0x000000010c6131a7 CFRunLoopRunSpecific + 567  
11 GraphicsServices 0x000000011a930d85 GSEventRunModal + 139  
12 UIKitCore 0x00000001220ba4df -[UIApplication \_run] + 912  
13 UIKitCore 0x00000001220bf39c UIApplicationMain + 101  
14 FinChat 0x000000010af227a8 main + 56  
15 libdyld.dylib 0x0000000118e11bbd start + 1  
)  
libc++abi: terminating with uncaught exception of type NSException

---

<div class="post-metadata">

**Author:** ![Woo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/woo/32/125_2.png) [@Woo](https://community.sendbird.com/u/Woo)\
**Post date:** [July 13, 2021, 12:37am UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/8 "2021-07-13T00:37:28Z")

</div>

Got it. Please use 226 version until we release new version. (226 is enough for a while since local caching is still not GA)

---

<div class="post-metadata">

**Author:** ![Tez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tez/32/146_2.png) [@Tez](https://community.sendbird.com/u/Tez)\
**Post date:** [July 15, 2021, 7:47am UTC](https://community.sendbird.com/t/ios-always-crashes-when-deleting-a-channel-sbdmessagedatabase/2621/9 "2021-07-15T07:47:28Z")

</div>

@finchat  
We have released the hotfix version.  
Please update version to **SendBirdSDK 3.0.228**.
