home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.35k stars 655 forks source link

Android Mobile App Intermittently Slow #3396

Open MaxK99 opened 1 year ago

MaxK99 commented 1 year ago

Home Assistant Android app version(s): 2023.1.1-full Android version(s): 13 Device model(s): pixel 4a Home Assistant version: 2023.2.5 HA OS Last working Home Assistant release (if known):

Description of problem, include YAML if issue is related to notifications: The Android mobile app is intermittently slow to startup (5-10 seconds to start) and slow when navigating in the app (up to 5 seconds to navigate to a different screen). The issue is persistent when it occurs until the phone is rebooted. This issue has been reported by others in the Home Assistant Forum

https://community.home-assistant.io/t/mobile-app-2022-11-0-full-slow-lately-solved-after-reset-but-now-slow-again/504816

https://community.home-assistant.io/t/ha-app-has-become-slow-on-android/534341/6

Companion App Logs: homeassistant_companion_log_1-28-2023_5-59-6.txt

Screenshot or video of problem:

Additional information: WebView version: 110.0.5481.153 No custom cards No HACS components

jpelgrom commented 1 year ago

I encountered something similar a few times, looked like it was something in the WebView causing it to slow down as other parts of the app remained fast.

Can you check:

MaxK99 commented 1 year ago

Unfortunately, it can be a few weeks before the issue occurs. But I will do those checks when it does happen again. Hopefully, others will jump in and provide feedback sooner.

There was a recent mention about how clearing the cache on the phone resolved the same issue.

g-kiss commented 1 year ago

This issue occurs for me too. The cache clearing does not solve the problem, only the mobile restart.

ciB89 commented 1 year ago

I also have this issue. I often also get the screen that the instance is not available (where I can decide to wait, check internal URL etc.) when I open up the app. It's like there is a massive delay/package loss.

Mincka commented 1 year ago

In my case, I usually "fix" this by rebooting the phone but it comes back quickly. I am using a Google Pixel Pro 7 but I remember I also had this behavior with my Galaxy S20+ few months back, this is clearly not something recent. I just tried to purge the cache but it did not change anything, however, I used "Force Stop" and it immediately fixed it. And I mean not just swiping up the app in the app switcher, it does not stop really stop it.

dshokouhi commented 1 year ago

Based on this comment and the description from this issue I think this might be a frontend issue and not an app issue.

Home Assistant should automatically reconnect with a maximum of 1 second delay.

I often also get the screen that the instance is not available (where I can decide to wait, check internal URL etc.) when I open up the app.

This is unrelated to this issue. The only reason why that pop-up will show up is either a connection error to the server or your server did not respond within 10 seconds.

And I mean not just swiping up the app in the app switcher, it does not stop really stop it.

Some manufacturers will implement force stopping an app when you swipe it away but typically that does not happen and it just stops the activity.

ciB89 commented 1 year ago

I often also get the screen that the instance is not available (where I can decide to wait, check internal URL etc.) when I open up the app.

This is unrelated to this issue. The only reason why that pop-up will show up is either a connection error to the server or your server did not respond within 10 seconds.

Well, I only get this message when I open up the app, and webview works perfectly fine and responsive, so I guess this seems to be at least not a network issue.

Mincka commented 1 year ago

I can confirm the behavior described by @ciB89. It becomes so slow at some point that the message is shown. The slowness is the same on Wi-Fi or 4G, using internal or external URL. It's like having a throttling preset to Slow 3G enabled.

jpelgrom commented 1 year ago

I actually have a video of it being slow to load from last December with dev tools open, showing unexpected gaps in the timeline with the webview waiting on basically nothing? Not sure where to start with determining where the issue lies / how to fix it though, and I haven't seen this behavior recently.

https://user-images.githubusercontent.com/8148535/223224266-47917152-fe71-4d3a-883d-4e3e8d667b2a.mp4

Mincka commented 1 year ago

Maybe it's not related to network but to high CPU usage due to multiple instances of the app (as seen in #2749 for instance, no pun intended). If one clicks on notifications on a regular basis, new instances are spawn and the overall allocated CPU becomes high. Consequently, it degrades slowly over time. This could be the reason why killing the app (or rebooting the phone) fixes the issues, all the instances are killed.

dshokouhi commented 1 year ago

Maybe it's not related to network but to high CPU usage due to multiple instances of the app (as seen in #2749 for instance, no pun intended). If one clicks on notifications on a regular basis, new instances are spawn and the overall allocated CPU becomes high. Consequently, it degrades slowly over time. This could be the reason why killing the app (or rebooting the phone) fixes the issues, all the instances are killed.

That code has been there for a very long time, as in well over a year. This issue has only recently started back in November so the timing and dates don't match up.

liollury commented 1 year ago

Hello, I also have this problem and it started at the same time as adding an Android widget and quick access with the notification bar (maybe a coincidence) . I notice too this is temporarely resolve with device reboot.

Mincka commented 1 year ago

It's not easy to reproduce but I ran a top and saw this while the application was slower to load the home page. image

Sorry the cropped output... PID 11884 is the webview: image

dshokouhi commented 1 year ago

@Mincka managing CPU tasks is out of scope for any android app, that is up to the system to handle it.

Also we no longer keep those newly spanned tasks in history, they are removed as soon as they user navigates away from it. That change was also done a while ago.

If that were indeed the issue then it would be very easy to reproduce actually.

Mincka commented 1 year ago

Fine, but if you have some helpful recommendations to find out the root cause, don't hesitate to share.

dshokouhi commented 1 year ago

At this point its probably best we look for whats common amongst all the users.

  1. What version of HA core the user is on (even better if we can tell which version the issue started as we suspect this started in November 2022)
  2. What version of the app the user is on
  3. What WebView package and version is installed on the device
  4. If the user has any custom cards or components (may be trivial as I think some users don't have anything custom). For this keep in mind we care about if the card is loaded as a resource in Lovelace, it does not have to be used just loaded.
  5. What type of HA setup, HA core, Docker, Supervisor, HA OS
  6. Anything else that we may consider to be common.

For me I am unable to reproduce this on my Pixel 7 Pro. HA core is on 2023.3 (only running HA core), WebView package is Googles and version is 110. Only custom card I use is custom weather and auto entities.

MaxK99 commented 1 year ago

@dshokouhi Edited original post with requested details. I have not had a recurrence since original post yet.

quhar commented 1 year ago

I'm also experiencing this issue for few months. Clearing app cache doesn't work, reboot helps and clearing app user data too.

  1. HA core version 2023.2.5, but this issue is showing up since ~November
  2. 2023.1.1-full, same as the above it's there for a while. Usually reappears ever couple of weeks. Phone is Google Pixel 6 Pro.
  3. WebView version is 111.0.5563.57
  4. Custom resources:
    • /hacsfiles/battery-state-card/battery-state-card.js?hacstag=256292682211
    • /hacsfiles/bignumber-card/bignumber-card.js?hacstag=187245418006
    • /hacsfiles/clock-weather-card/clock-weather-card.js?hacstag=5226340191011
    • /hacsfiles/lovelace-auto-entities/auto-entities.js?hacstag=1677445841121
    • /hacsfiles/lovelace-fold-entity-row/fold-entity-row.js?hacstag=150781994220
    • /hacsfiles/lovelace-multiple-entity-row/multiple-entity-row.js?hacstag=178921037441
    • /hacsfiles/lovelace-mushroom/mushroom.js?hacstag=444350375253
    • /hacsfiles/mini-climate-card/mini-climate-card-bundle.js?hacstag=268163975243
    • /hacsfiles/mini-graph-card/mini-graph-card-bundle.js?hacstag=1512800620110
    • /hacsfiles/mini-media-player/mini-media-player-bundle.js?hacstag=1485208381165
    • /hacsfiles/power-flow-card/power-flow-card.js?hacstag=484538222261
    • /hacsfiles/scheduler-card/scheduler-card.js?hacstag=286270157327
    • /hacsfiles/simple-thermostat/simple-thermostat.js?hacstag=158654878250
    • /hacsfiles/sun-card/sun-card.js
    • /hacsfiles/upcoming-media-card/upcoming-media-card.js?hacstag=146783593043
    • /hacsfiles/vacuum-card/vacuum-card.js?hacstag=261291295263
    • /hacsfiles/weather-card/weather-card.js
    • /webrtc/webrtc-camera.js?v3.1.0
  5. HA Docker
  6. My wife who is using companion app much less often (on Pixel 5a), doesn't receive many notifications doesn't experience this problem.

Logs just after app was started. homeassistant_companion_log_2-9-2023_21-48-50.txt

Deejayfool commented 1 year ago

Hello,

I also have the exactly same problem since few months and forcing to stop the App fixes the bug for some times too (but not definitely).

  1. What version of HA core the user is on (even better if we can tell which version the issue started as we suspect this started in November 2022) 2023.3.3

  2. What version of the app the user is on 2023.1.1-full

  3. What WebView package and version is installed on the device 110.0.5481.153

  4. If the user has any custom cards or components (may be trivial as I think some users don't have anything custom). For this keep in mind we care about if the card is loaded as a resource in Lovelace, it does not have to be used just loaded. -> Battery State Card -> Hass Shutter Card -> Light Entity Card -> Grocy Meal Plan Card -> Template Entity Row -> Xiaomi Vacuum Card -> Xiaomi Vacuum Map Card -> Kiosk Mode

  5. What type of HA setup, HA core, Docker, Supervisor, HA OS HA OS

  6. Anything else that we may consider to be common. I have this bug on my Pixel 7 Pro.

Tassel8062 commented 1 year ago

Also see this exact problem on pixel 6 pro with the latest version of the companion app. Loading HA via a browser on the same phone works quick.

wouterrutgers commented 1 year ago

Hi,

Having this problem too since a few months.

What version of HA core the user is on (even better if we can tell which version the issue started as we suspect this started in November 2022) 2023.3.4

What version of the app the user is on 2023.1.1-full

What WebView package and version is installed on the device 110.0.5481.153

If the user has any custom cards or components (may be trivial as I think some users don't have anything custom). For this keep in mind we care about if the card is loaded as a resource in Lovelace, it does not have to be used just loaded. -> WebRTC camera -> Frigate -> Powercalc -> Circadian Lighting -> Pyscript -> Dahua -> Fontawesome -> Dwains Dashboard -> Volkswagen We Connect ID -> Daikin Residential Controller

What type of HA setup, HA core, Docker, Supervisor, HA OS HA OS

Anything else that we may consider to be common. I have this bug on a Samsung Galaxy S22 Ultra.

felipecrs commented 1 year ago

With this bug the companion app is basically unusable. It takes 50 seconds to load on the app versus 5 seconds on Chrome.

Galaxy S23 Ultra.

It's as if the app had a data speed cap.

https://user-images.githubusercontent.com/29582865/225815334-fa303024-0fc3-4e65-9e06-05036b8e4f55.mp4

bmcclure commented 1 year ago

I've also been experiencing this issue for a month or two at least. I assumed I was having a WiFi problem until I tested the web app and it loaded really quickly.

Every time I try and open the Android app it spins for a while, gives me the error about not finding my instance, then starts loading a few seconds later.

But then every page I go to within HA just sits on a blank window for 5-10 seconds until it starts loading in slowly.

MaxK99 commented 1 year ago

I am experiencing this issue again since first posting the details above. Nothing has changed version-wise except I have the March 5, 2023 security update.

There is nothing in the Core or Supervisor logs. I did captured the companion log again. homeassistant_companion_log_2-18-2023_14-52-4.txt

@dshokouhi I will try to keep my phone in this state in case you want me to check anything else.

OverFlow636 commented 1 year ago

Also experiencing this issue for the last 2months or so, it even affects the ble transmitter, so my espresense setup thinks I'm not home because the app stops broadcasting. I use the persistent websocket connection if that changes anything.

Notifications are also significantly delayed during this time, I have some door open notifications which will trigger 5 mins after sent instead of <1 second

When I open the app it's very slow to open, complains about ha server being unreachable then eventually starts up, but navigating between dashboards is very slow.

I just force stop the app and re open and it's fast again.

bunicb commented 1 year ago

Same here on a Pixel 6A and OnePlus Nord. Versions of the companion app are basically always latest, Core HA is currently 2023.3.6.

Notifications are delayed at that time, location of apps in zones doesn't update correctly for a while.

Force stop seems to alleviate the problem for a while.

vrmtm commented 1 year ago

When the application starts running slowly, I looked at what it shows in debug mode. It seems that in addition to the main instance, there are also several others that are marked as detached. Killing/reloading the application not only does not help, but after each kill/reload a new detached instance appears. The only thing that helps is rebooting the device or force stop. This helps for a few days or a week, then everything happens again.

ha_error

wouterrutgers commented 1 year ago

To add to this, it seems that it is also draining my battery quicker.

I had removed the app for a while and used the web app, and my phone used to live a lot longer. Reinstalled the app because I missed the notifications (html5 notifications are not as reliable), and now it is getting drained a lot faster again.

No extra sensors or w/e enabled, just basic install with default settings. So might be related to this issue and the higher CPU usage others have noticed.

dshokouhi commented 1 year ago

@wouterrutgers for battery drain issues please refer to our troubleshooting guide, as far as I know no other user in this thread has mentioned high battery drain so its possible you have some settings to adjust or something that needs to be cleaned up.

https://companion.home-assistant.io/docs/troubleshooting/faqs#android-app-battery-drain

VNRARA commented 1 year ago

Try to remove the internal ip and wifi ssid from the companion app completely. I found that mine significantly sped up after doing that.

felipecrs commented 1 year ago

Thanks for the suggestion, but I never had it there.

VNRARA commented 1 year ago

Can you try filling it in and restarting and removing it again?

felipecrs commented 1 year ago

Ok, just did. Let's see how it behaves.

felipecrs commented 1 year ago

Just to update, I tested it, and it has apparently helped for a while. Just like cleaning the app cache does.

But the problem returns.

nagyrobi commented 1 year ago

Same for me, unfortunately.

bartgrefte commented 1 year ago

Same here since a couple of days (could be a bit longer, don't use the app every day), though strangely it resolved itself sometime last night, without doing anything.

What version of HA core the user is on (even better if we can tell which version the issue started as we suspect this started in November 2022) Started while on HASS OS 9.5 and Core 2023.4.4, but not directly after updating to these versions. The issue continued after updating to 10.1 / 2023.5.2.

What version of the app the user is on 2023.3.0-full

What WebView package and version is installed on the device Android System WebView 112.0.5615.135.

If the user has any custom cards or components (may be trivial as I think some users don't have anything custom). For this keep in mind we care about if the card is loaded as a resource in Lovelace, it does not have to be used just loaded. Nothing custom, as for addons: File editor, Glances, Mosquitto Broker, SQLite Web, Terminal & SSH.

What type of HA setup, HA core, Docker, Supervisor, HA OS HA OS, OVA image in VMware Workstation 15.5.6, host OS W10 x64 LTSC 1809 (17763.1999).

Anything else that we may consider to be common. Samsung Galaxy S20 FE 5G, DNS lookup is done using PiHole. Since the memory card of my RPi recently died and had to do a clean install, I thought the problem was there, seems it's not.

clau-bucur commented 1 year ago

Have the same issue, for quite a long time now. Apparently clearing cache is the only short-term solution for the problem.

energywave commented 1 year ago

I confirm the same behavior from long time too. When it happens it can be resolved by clearing the app cache and force the app to exit, then it works again as normal, until it happens again. Not the worse issue when you understand how to overcome but I'm sure there's many person that don't know what to do and uninstall/reinstall to resolve, losing all sensor configuration...

werkstrom commented 1 year ago

https://github.com/home-assistant/core/issues/100982 Confirm same behavior. More info in the linked issue

smarthomefamilyverrips commented 1 year ago

Same here!

gitlaman commented 1 year ago

Mine is set to auto clear cache every night with 1Tap Cleaner Pro, since i started the auto clear cache i disabled the auto reboot HA automation (i thought that the database was making the lags) and for 10 days the HA app is working flawless.

smarthomefamilyverrips commented 1 year ago

Yes clearing cache or reboot phone solves the problem for a while but this should not be the solution as before not had this issue

earion68 commented 1 year ago

I had a similar issue lately and spent days investigating. Long story short, it was due to the file known_devices.yaml that was too big, like several megabytes (this was due to a chatty BLE device tracker integration). Reduced the file to like ~1000 lines and after a HA reboot it was day and night.

felipecrs commented 1 year ago

Where can I find this file?

earion68 commented 1 year ago

Where can I find this file?

At the root of /config next to configuration.yaml

nagyrobi commented 1 year ago

@earion68 that's just a coincidence. No use of that file here (not even present), issue still appears occasionally.

werkstrom commented 1 year ago

Would have to initially side with @nagyrobi. on this one. A. That file is not present on my system and B. Restarting the phone would not (unless there is some specific code doing it) adjust that file on the server and reload the server (as my issues are resolved without server restart). Not saying your issue wasn't resolved as per your description @earion68 . Just saying it is likely another issue. IMHO. Thanks for your input though 👍

adamantivm commented 1 year ago

Same behavior for me since a few HA core releases ago. Interested in helping testing or doing anything I can to help nail down the issue.

adamantivm commented 1 year ago

What version of HA core the user is on

Home Assistant 2023.10.3 Supervisor 2023.10.0 Operating System 11.0 Frontend 20230608.0 - latest

What version of the app the user is on

2023.10.2-full

What WebView package and version is installed on the device

117.0.5938.153

If the user has any custom cards or components (may be trivial as I think some users don't have anything custom). For this keep in mind we care about if the card is loaded as a resource in Lovelace, it does not have to be used just loaded.

Hmm ... nothing that I wrote myself. The most advanced I have is a Thermostat card, but it's the defualt one as far as I know.

What type of HA setup, HA core, Docker, Supervisor, HA OS

HA OS

Anything else that we may consider to be common.

Works fast on Web but get slow on mobile. Restarting Home Assistant core makes it fast again for a while, but after hours / a day it gets slow again. Force stop on Android also makes it fast again - TBD for how long.

werkstrom commented 1 year ago

After some more testing I can confirm the issue is temporarily resolved by flushing the app cache. It does however eventually return. Very random when it occurs. I cannot see any pattern to it.