xmtp / xmtp-android

XMTP client SDK for Android applications written in Kotlin.
https://xmtp.github.io/xmtp-android/
MIT License
33 stars 12 forks source link

Bug: streamDecryptedMessages from a group not working when streaming client sends message #190

Closed cameronvoell closed 3 months ago

cameronvoell commented 7 months ago

Describe the bug

When we call group.streamDecryptedMessages() from a group that is referenced by client alix, and then alix sends a message, that message is not streaming.

Expected behavior

Messages sent from the streaming client, and other clients should both show up when we call group.streamDecryptedMessages(). See passing xmtp-ios test here: https://github.com/xmtp/xmtp-ios/pull/269

Steps to reproduce the bug

Run the new test testCanStreamDecryptedGroupMessagesFromSelf from this draft PR: https://github.com/xmtp/xmtp-android/pull/189

Issue is also re-produced in React Native SDK only on the Android Side, see https://github.com/xmtp/xmtp-react-native/pull/293/files

image
cameronvoell commented 7 months ago

Not immediately obvious why android group messages arent streaming from self, group.streamDecryptedMessages() looks like a pretty straightforward call to libxmtp, so not sure why the discrepancy with xmtp-ios 🤔

https://github.com/xmtp/xmtp-android/blob/5da219acc9c14c46fc35020e7a445725b28f5ce5/library/src/main/java/org/xmtp/android/library/Group.kt#L185-L194

cameronvoell commented 7 months ago

Issue was re-created in libxmtp repo, see libxmtp branch: cv/re-create-cant-stream-message-from-self

libxmtp android test app with errors:

ERROR - [libxmtp] receive error ReceiveErrors([Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])

see log below:

2024-03-04 09:53:28.779 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.782 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 2ff5b9d650be18c908c1a15c939243ae54500d06fc1faeca4c9dc36b3a8a80ce, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.799 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.805 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 6d9cbbdf51c18c101355cabb8610eaf5687d9a13b54b3c343b58de26da378ce1, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.822 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.827 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 0ddc2d21db965a5fbe3fadba236d1da2ccc539cd6ba03183d2546cc54443cf9d, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.847 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.848 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.848 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.856 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] error publishing intents Storage(DieselResult(DatabaseError(Unknown, "database is locked")))
2024-03-04 09:53:28.862 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.863 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.864 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.865 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] Error processing stream entry: Sync([Storage(DieselResult(DatabaseError(Unknown, "database is locked")))])
2024-03-04 09:53:28.866 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.866 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.867 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.871 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.871 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.871 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.872 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Skipped message streaming payload
2024-03-04 09:53:28.884 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.885 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.886 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.890 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] error publishing intents Storage(NotFound)
2024-03-04 09:53:28.892 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.892 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.894 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.894 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.895 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.896 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] Error processing stream entry: Sync([Storage(NotFound)])
2024-03-04 09:53:28.896 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.897 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.897 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.900 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([Storage(DieselResult(DatabaseError(Unknown, "database is locked")))])
2024-03-04 09:53:28.900 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Skipped message streaming payload
2024-03-04 09:53:28.907 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.907 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.907 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.910 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] error publishing intents Storage(NotFound)
2024-03-04 09:53:28.912 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.912 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.914 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.914 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.914 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.915 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] Error processing stream entry: Sync([Storage(NotFound)])
2024-03-04 09:53:28.916 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.916 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.916 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                        RatchetTypeError
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Skipped message streaming payload
2024-03-04 09:53:28.949 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.953 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 84199ba5f36bc580357d8ea1cdc60a9c0fc0bae2b23d5235661acc341a51348d, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.965 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.972 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 334ddde2d7c415f43ff5b8452fffb05d0e51be57dbdcdaf8d2e6bcb0d336b095, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.989 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.993 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: f265502fadc01708599d51a57ad5874de9ce33f77e0d8d1467c86e2598ab6720, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.995 19452-19452 App                     com.example.xmtpv3_example           I  Setting up conversation streaming