https://kotlinlang.org logo
#compose
Title
# compose
s

Spikey Sanju

06/06/2021, 10:15 AM
Hello All 👋 , Why
CombinedClickable
takes
1-2 seconds
to perform action?. Is there any workaround solution for this? Code in Thread 🙇
Sample Code 👀
Copy code
fun TaskItemCard(task: Task, onClick: () -> Unit, onDoubleTap: () -> Unit, onLongClick: () -> Unit) {
    // Emoji + (title + category)
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .combinedClickable(onClick = {
                onClick()
            }, onDoubleClick = {
                onDoubleTap()
            }, onLongClick = {
                onLongClick()
            }),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.Start
    ) {
        // Emoji Text View
        EmojiTextView(emoji = task.emoji)
        Spacer(modifier = Modifier.width(12.dp))

        // Title + Content
        Column(
            modifier = Modifier
                .align(Alignment.CenterVertically),
        ) {
            Text(
                text = task.title,
                style = typography.subtitle1,
                color = colors.onPrimary,
                maxLines = 1,
                overflow = TextOverflow.Ellipsis
            )
            Spacer(modifier = Modifier.height(12.dp))
            Text(
                text = task.category,
                style = typography.caption,
                color = colors.onPrimary.copy(.7f)
            )
        }
    }
}
s

ste

06/06/2021, 10:26 AM
It happens to me too at the very first click after app startup
s

Spikey Sanju

06/06/2021, 10:27 AM
Also I tried to use
tap gestures
to handle multiple touch events. But with those implementation also I face the same performance issue!
c

Colton Idle

06/06/2021, 1:01 PM
Romain has asked for any reproducable perf issues to be reported on the issuetracker for more visibility and so they can hopefully fix by 1.0 I would file there with the code and a video?
s

Spikey Sanju

06/06/2021, 1:02 PM
Sure gimme a moment will send you the code & video
👍 1
c

Colton Idle

06/06/2021, 1:48 PM
Take those samples and file a bug on issue tracker. 😁 I'm not on the compose team and have no idea why the issue might be happening.
1
r

Rick Regan

06/06/2021, 3:56 PM
ste: There have been a few discussions of performance at app startup, like this thread from Mar 11 https://kotlinlang.slack.com/archives/CJLTWPH7S/p1615475836408100 and this one from May 10  https://kotlinlang.slack.com/archives/CJLTWPH7S/p1620669472316800
2
l

Louis Pullen-Freilich [G]

06/06/2021, 5:28 PM
@matvei
m

matvei

06/07/2021, 10:30 AM
With the
combinedClickable
modifier, when you have
onDoubleClick
set, onClick will fire only after
300ms
of the click event, since we need to disambiguate between click and doubleclick and we need to wait 300ms for a potential doubleckick to happen (or not). This is the same way it works in the android views. We hopefully can do better, but this is exactly the issue on why
combinedClickable
is experimental, so proceed with caution on this one. This is most probably what is causing the delay in your case. If you see other delays and if you are able to provide a sample that will help me to reproduce the issue with the >300ms delay -- please file a bug and we will take a look.
1
s

Spikey Sanju

06/07/2021, 4:50 PM
Got it. Sure will file a bug!
6 Views