Skip to content

[BUG] ChannelMediaAttachmentsScreen crashes with duplicate item.id in LazyGrid #6034

@subramanian-zuper

Description

@subramanian-zuper

Bug Description

ChannelMediaAttachmentsScreen crashes intermittently with duplicate item.id values in LazyGrid causing key collisions.

Error

java.lang.IllegalArgumentException: Key "-1891661558-Loading" was already used. 
If you are using LazyColumn/Row please make sure you provide a unique key for each item.

Environment

  • stream-chat-android-compose: 6.28.0
  • stream-chat-android: 6.28.0
  • Android OS: 15 (API 35)
  • Architecture: arm64-v8a

Reproduction

StreamChatTheme {
    val mediaViewModelFactory = remember {
        ChannelAttachmentsViewModelFactory(
            cid = navTarget.cid,
            attachmentTypes = listOf(AttachmentType.IMAGE, AttachmentType.VIDEO),
        )
    }
    
    ChannelMediaAttachmentsScreen(
        modifier = Modifier
            .fillMaxSize()
            .statusBarsPadding(),
        viewModelFactory = mediaViewModelFactory,
        onNavigationIconClick = { performUpNavigation() }
    )
}

Steps

  1. Navigate to ChannelMediaAttachmentsScreen with multiple media attachments
  2. Crash occurs intermittently when multiple items have duplicate IDs

Stack Trace

java.lang.IllegalArgumentException: Key "-1891661558-Loading" was already used.
    at androidx.compose.foundation.lazy.grid.LazyGridKt$rememberLazyGridMeasurePolicy$1$1.invoke-0kLqBqw (SourceFile:837)
    at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$1$2$1.invoke-0kLqBqw (SourceFile:14)

Additional Info

  • Crash ID: 35a4ed7c-e6aa-4417-a588-61061b090979
  • Session ID: 0834bdd0-1607-4749-9932-fb990116c5b9
  • Timestamp: 2025-12-04 11:34:31 UTC
  • Not consistently reproducible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions