BlueBubblesApp / bluebubbles-server

Server for forwarding iMessages to clients within the BlueBubbles App ecosystem

Home Page:https://bluebubbles.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Messages will "shuffle" and be out of order according to time

seanlowe opened this issue · comments

Hello, not sure if this is the correct repo to make this issue in. If it's not, please direct me to where I should post this.

Problem: Messages get wildly out of order according to send time and make the conversation hard to follow.

Expected Result: Messages sent stay in the order of which they are sent / received / delivered (with some give and take due to latency or what have you).

Actual Result: I am able to send a message, then receive a reply a couple minutes later. Upon opening the app the original message will display after the reply and further messages can exasperate this problem.

Description: I previously made this comment on issue #570 about my chats being out of order.

The issue I was seeing didn't quite match the topic of that issue and the next comment told me to check my time sync on the mac and my android. Both are pretty close to the actual time and not far enough apart that messages should display incorrectly minutes after they've been sent.

It happens regularly but normally not from a Desktop client unless I'm seeing it happen on the Android client and then open the desktop client. Then it's usually still messed up.

Well today it happened to a message that I had sent like 5 minutes prior. I opened up the desktop client to see if there was any additional information I could find on it. I found in the "Right Click > More... > Message Info" that my original message had a dateCreated value that is later than the dateSent value.

Here's the "original" message

{
     "ROWID": 3343,
     "originalROWID": 3676,
     "guid": < guid here >,
     "handleId": 1,
     "otherHandle": 0,
     "text": <some text here >,
     "subject": null,
     "country": null,
     "_error": 0,
     "dateCreated": "December 11, 2023 9:47:51 AM", // <----- x
     "dateRead": null,
     "dateDelivered": "December 11, 2023 9:42:34 AM", // <--- x
     "isFromMe": true,
     "hasDdResults": false,
     "datePlayed": null,
     "itemType": 0,
     "groupTitle": null,
     "groupActionType": 0,
     "balloonBundleId": null,
     "associatedMessageGuid": null,
     "associatedMessagePart": null,
     "associatedMessageType": null,
     "expressiveSendStyleId": null,
     "handle": null,
     "hasAttachments": false,
     "hasReactions": false,
     "dateDeleted": null,
     "metadata": "{}",
     "threadOriginatorGuid": null,
     "threadOriginatorPart": null,
     "hasApplePayloadData": false,
     "dateEdited": null,
     "wasDeliveredQuietly": false,
     "didNotifyRecipient": false,
     "isBookmarked": false,
     "attachments": [],
     "attributedBody": [
          {
               "string": < message here >,
               "runs": [
                    {
                         "range": [
                              0,
                              380
                         ],
                         "attributes": {
                              "__kIMMessagePartAttributeName": 0,
                              "__kIMFileTransferGUIDAttributeName": null,
                              "__kIMMentionConfirmedMention": null
                         }
                    }
               ]
          }
     ],
     "messageSummaryInfo": [],
     "payloadData": null
}

and here is the "response" message:

{
     "ROWID": 3344,
     "originalROWID": 3677,
     "guid": < guid >,
     "handleId": 1,
     "otherHandle": 0,
     "text": < response text >,
     "subject": null,
     "country": null,
     "_error": 0,
     "dateCreated": "December 11, 2023 9:46:36 AM", // <----- x
     "dateRead": null,
     "dateDelivered": null,
     "isFromMe": false,
     "hasDdResults": false,
     "datePlayed": null,
     "itemType": 0,
     "groupTitle": null,
     "groupActionType": 0,
     "balloonBundleId": null,
     "associatedMessageGuid": null,
     "associatedMessagePart": null,
     "associatedMessageType": null,
     "expressiveSendStyleId": null,
     "handle": {
          "ROWID": 17,
          "originalROWID": 1,
          "address": < address >,
          "formattedAddress": < formatted address >,
          "service": "iMessage",
          "uniqueAddrAndService": "< address >/iMessage",
          "country": "US",
          "color": null,
          "defaultPhone": null,
          "defaultEmail": null
     },
     "hasAttachments": false,
     "hasReactions": false,
     "dateDeleted": null,
     "metadata": "{}",
     "threadOriginatorGuid": null,
     "threadOriginatorPart": null,
     "hasApplePayloadData": false,
     "dateEdited": null,
     "wasDeliveredQuietly": false,
     "didNotifyRecipient": false,
     "isBookmarked": false,
     "attachments": [],
     "attributedBody": [
          {
               "string": < response text >,
               "runs": [
                    {
                         "range": [
                              0,
                              210
                         ],
                         "attributes": {
                              "__kIMMessagePartAttributeName": 0,
                              "__kIMFileTransferGUIDAttributeName": null,
                              "__kIMMentionConfirmedMention": null
                         }
                    }
               ]
          }
     ],
     "messageSummaryInfo": [],
     "payloadData": null
}

This behaviour makes it very difficult to use the android app (I tend to just use the desktop apps which seem not to have this problem) but I don't want to limit myself to only being able to use BlueBubbles at a computer

Could you join our discord so we can troubleshoot more? Ping me @ tneot01

Here's a recap of the discussion and troubleshooting that happened over Discord, recorded here for posterity should anyone else run into this issue:

Tanay = tneotia
seanlowe = pheeonyx

Tanay — 12/11/2023 9:07 PM
Hey, the main way to debug is to see the data inside your imessage database on the Mac
You can download a sqlite viewer like "DB browser for sqlite"
Then open the ~/Library/Application Support/Messages/chat.db
Open the messages table and then find the message you sent as an example by its guid
You will want to look for the date created column and the date delivered column
Send those two values here
If you need more explanation on any of the steps just lmk

pheeonyx — 12/24/2023 11:35 AM
Sorry it took so long to respond but I have the data from those two messages:

first message (originally sent at 9:42 AM)
date (assuming that's date created) was 724006071830762368
date_delivered was 724005754169100288

second message (originally received at 9:46 AM)
date was 724005996570869888 --
side observation: When viewing "message info" in the BB client dateRead is null but in the DB it was 725135321

Tanay — 12/24/2023 3:04 PM
if you received a message that makes no sense that the dateRead has a value
but yeah looks to be an issue with the mac
because the first message date created is 9:47 (and the date delivered is 9:42) so that makes no sense

pheeonyx — 12/24/2023 3:10 PM
How do we know it's an issue with the mac? I can send messages back and forth from the iMessage client on the Mac and it doesn't shuffle around. Are there things I can do, settings or configuration-wise to mitigate this behavior?

Tanay — 12/24/2023 3:12 PM
iMessage seems to order messages internally differently than we do (we dont know exactly how)
we order by date created as it seems to make the most sense
but it is a known issue specifically on macos high sierra, which your bio says you have

pheeonyx — 12/24/2023 3:15 PM
Hm, interesting. Well, thanks for the explanation. If we ever do find out some way to fix it then that'd be phenomenal but I won't hold my breath. Thanks

Tanay — 12/24/2023 3:20 PM
the only way is probably to brute force it and take the date created or date delivered, whichever is earlier

So if we ever come back to this issue and decide to implement that brute-force method, I'd be grateful and willing to help however I can, whether that be testing or coding.