SBSMChannelCollectionDelegate when receiving a new message triggers twice the .update event

@woo I’ll send you a private message with a video where I have breakpoints set up where you can see, that .update gets called twice.

@Cris_Warren I was looking at wrong point :sob: It was a bug in SendBirdSDK that was introduced in recent patch. I will release patch of SendBirdSDK and will let you know (you need to pod update to get latest SDK version)

1 Like

Thanks @Woo I’ll wait for the update and let you know if the issue got fixed!

@Cris_Warren @a1039090507 @ganweiming Please update SendBirdSDK with pod update and confirm its version is v3.0.187. Let me know if the bug is fixed you guys end. Thanks!

1 Like

Thanks so much, it work for me

it work for me
pendding message has a messageid of 0, however, after sending successfully, the value of messageId is still 0. Is this normal?

pending message id 0 is normal, and it doesn’t get affected by sending status. You have to use the object from callback.

1 Like

am I writing this correctly?

- (void)setPendingMessage:(SBDBaseMessage *)message {
    if (message) {
        [self.collection appendMessage:message];
    }
}

- (void)setSentMessage:(SBDBaseMessage *)message {
    if (message) {
        [self.collection updateMessage:message];
    }
}

[self.collection updateMessage:message] this method can cause triggers .update event?If so, I’m not working at the moment

@Woo, the issue got fixed in some devices, some didn’t experience the issue for a while but then it came back in. https://share.getcloudapp.com/Wnub7b6J

Are you sure both simulators running on latest SDK?

I am not using simulators, this is from a build sent to my project manager to test the issue, it worked for around an hour then the issue started happening again.

Ok, it would be helpful if you can tell me whether it consistently happens or works when you restart your app. Did you install latest SDK on both side? and would you try to comment out markAsRead and tell me if this happens?

the issue is behaving the same way, mark as read is commented out, although the chat view controller would need to be open for it to be called… when the app is active, issue happens, when sending the app to aground and coming back in data is correct, or closing and opening the app, has correct data, but when receiving the messages in the app, being active issue happens.

So even though markAsRead is commented out, still happening? Yes I know markAsRead is needed, I just want to make check if it causes the issue. And you didn’t answer my question, could you confirm both ends use latest SDK version?

Oh I see the same result when I enter and exit and re-enter again… I will dig again. One last thing, I observed same issue when

  1. UserA (chat view) sends a message to UserB (channel list view)
  2. UserB enter to chat view and send a message
  3. UserB goes back to channel list view
  4. UserA sends a message again

and it worked again from above scenario when

  1. UserB enter to chat view and back to channel list view

Could you confirm this?

1 Like

And if you made your project from the sample, there’s memory leak that chat view is not released properly -> which causes to call markAsRead when other user sends a message. I’ve updated sample app (fixed memory leak), and I do not see the problem anymore. Please check the sample app :slight_smile: Thanks

1 Like

@Woo I’ve made changes to avoid memory leak just in case it was happening, issue still there. It did not work again after running that scenario. and yes, both ends are running on the same SDK version.

Can you check sample? I updated it yesterday. Could you please run the sample on your devices and see if its happening?

1 Like

I could not run the sample, first it says there’s no message.requestState() and I had to replace with requestStatus(), second as soon as I login, the app crashes after GroupChannelsViewController loads, Thread 5: EXC_BAD_ACCESS (code=2, address=0x16cff7ff0)

  `19 ->  0x104550ff0 <+68>:  cbz    w0, 0x10455100c           ; <+96> at SBDBaseMessage+SyncManager.m:93:34`

warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

but in my project again moving the app to background and then back in, will return the correct unread message count, so the channel is not being marked as read.