MicrosoftDocs / msteams-docs

Source for the Microsoft Teams developer platform documentation.
https://aka.ms/teamsdev
Creative Commons Attribution 4.0 International
288 stars 511 forks source link

Performance degradation on iOS devices when interacting with bots or using adaptive cards #8136

Open bandtank opened 1 year ago

bandtank commented 1 year ago

When interacting with a bot in a personal chat, the GUI becomes sluggish and unresponsive in many circumstances. The problem is exacerbated whenever an adaptive card is present, especially if the card includes an embedded card which is activated by an ActionSet that shows or hides the embedded card.

Based on my experience with iOS app development, it appears the main thread is being used to process everything, which is not the recommended way to implement the renderer. Simple things like typing a message to the bot can be slowed down significantly depending on what is currently being displayed. More complex activities, such as toggling the visibility of an adaptive card, can cause the GUI to become unresponsive for several seconds.

This behavior is reproducible on multiple phones, iOS versions, and Teams versions. I have not noticed the performance issues on other platforms. In addition, the issue does not seem to occur in chats with humans even if a bot is present in the group chat; the only time I experience the issue is in a chat with a bot by itself. Without better access to the Teams debug environment, I am unable to tell if the problem occurs in channels.

What would be the most helpful way to demonstrate the issue?

This is similar to #1657. I want to emphasize that the problem occurs even when adaptive cards are not being used or visible on the screen, but the performance degradation is much more severe when adaptive cards are present. That's why I think the issue is not directly due to adaptive cards.

ghost commented 1 year ago

Hi bandtank! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

bandtank commented 1 year ago

I uploaded a video of the behavior here. The first few seconds show the stutter while typing or deleting characters. The rest of the video demonstrates the sluggish and unresponsive GUI when scrolling through a bot chat, especially when cards are displayed. This problem does not happen on Android as far as I can tell.

Meghana-MSFT commented 1 year ago

@bandtank - Thank you for reporting this issue, we will check this and get back to you.

Meghana-MSFT commented 1 year ago

@bandtank - We have shared this issue with engineering team, we will get back to you. Thanks!

bandtank commented 1 year ago

I tested a new bot that does not return any adaptive cards. The chat has only text responses. I noticed delays while adding and removing characters from the input element, scrolling through the chat history, and interacting with message extensions. It's subtle, but it's there.

There is also a noticeable delay when tapping on the bot to enter the personal conversation. I have experienced this since early 2022 when I started working with Teams bots. It appears to be the same issue - the main thread is handling everything instead of using dispatch queues for data-intensive tasks. This is fresh on my brain because my team literally had the same problem last week while developing an iOS app. The behavior is exactly the same as what I experienced.

Meghana-MSFT commented 1 year ago

Thank you for the additional inputs, engineering team is looking into this. We will get back to you. Thanks!

tn-halfspace commented 2 months ago

This issue is still there. I can't deploy an easy bot to the users, because iOS app is lagging so hard. Even opening up the chat takes 10+ seconds...

Any news here?

bandtank commented 2 months ago

@tn-halfspace The issue has not been addressed in any capacity as far as I can tell. In fact, the delay is longer now than it was when I filed the bug. I can't believe this hasn't been fixed. It impacts every iPhone and iPad.

tn-halfspace commented 2 months ago

Isn't this quite insane? I'm facing this issue only for the deployed chat, for the local one (with dev tunnel) it's completely fine... I wonder what makes it break then. Maybe there is a workaround?

bandtank commented 2 months ago

Yes, it is completely insane. I have not found a workaround after many hours of experimentation. The app has a threading issue, which is a fundamental flaw. A query is made to fetch chat data, which happens in the same thread that draws the UI and manages user input. Until the work for each part of the process is separated into different threads, the problem will remain.