Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phone becomes slow and unresponsive #63

Open
lispykid opened this issue Oct 23, 2020 · 22 comments
Open

Phone becomes slow and unresponsive #63

lispykid opened this issue Oct 23, 2020 · 22 comments

Comments

@lispykid
Copy link

I could reproduce this with an Xperia 10 and an Xperia X compact.
After keeping the app an Bluetooth running for a couple of hours, the system slows to a crawl an eventually becomes unresponsive so that only a hard reboot can restore it.

@omichalek
Copy link

I think I have similar experience on Xperia 10, without having to reboot anyway. I believe it happens out in the wild where I assume many BT devices are present (public transportaion, etc.)

@llewelld
Copy link
Owner

Yes, this is something I get too, but I've not been able to figure out the cause unfortunately. Any more info about this would be appreciated.

deepbluev7 wrote the following on OpenRepos:

I've noticed something strange: When I have this app running and scanning active, sometimes the whole Sailfish UI becomes unresponsive. I managed to catch it in the act and it seems like statefs was using 100% CPU. I'm using an Xperia X Compact, did anyone else have a similar issue? Seems to mostly happen in crowded places like public transport.

I plan to follow up the statefs lead. On top of that, opening the Bluetooth page in the Settings app shows the phone is picking up a lot of devices. I'm not sure if it's possible for Contrac to perform a BLE scan for a particular service without activating the general scan (this is down to bluez), but it's possible all these things are related.

@dryo
Copy link

dryo commented Nov 21, 2020

Hi @llewelld,
this definitely needs attention. I can't use the app (living in Berlin) because after a while the phone gets unusable. Really unusable like being unable to answer the phone or wake the device up. Additionally, after a forced reboot all I have is #71 .

How can I help to debug? Can I produce some logs that will help you? Have you been able to track this down?

@llewelld
Copy link
Owner

llewelld commented Dec 6, 2020

After having a look into this, there are a couple of possible reasons this may be happening. What would be really helpful is if anyone who experiences this could let me know:

  1. Do you have the Bluetooth switch active in your top menu (see the screenshot).
  2. If you do, does removing the switch from the top menu help?

It's hard to tell for me looking at the code alone, and although I've experienced the slowdown myself, I've not been moving around busy areas recently, so I can't be certain whether removing it has improved things for me, or if it's just coincidence. Any input any of you can give here would therefore be really helpful.

BluetoothSwitch

@dimpflmoser
Copy link

Actually yesterday I reactivated Contrac and removed Bluetooth from the top menu. Since then my phone has behaved normally, however I hardly met anyone and probably have not received many keys.

@dryo
Copy link

dryo commented Dec 28, 2020

Hi @llewelld,

I have the bluetooth icon there and removed it for testing purposes. Unfortunately it does not help. I tested it twice today while taking a long walk through the city and the phone got very unresponsive (no other chance but rebooting - contrac showed ~ 2200 contacts after reboot) and then after a while again quite unresponsive (disabled send/receive in contrac before it was too late to operate the phone).

So this does not help.

Any other ideas? I could send some logs if you want. Just tell me how to produce these.

I think it's very unfortunate that you came so far but now it's not usable. The main issues are this one and #71. For the rest there seem to be workarounds.

@bionade24

This comment has been minimized.

@bionade24
Copy link
Collaborator

For anyone who doesn't know what's statefs, too: https://sailfishos.org/wiki/Networking

@bionade24
Copy link
Collaborator

I didn't experience this isssue in the last month. Did anyone? Maybe it's somehow solved and not a problem anymore.

@dimpflmoser
Copy link

I didn't experience this isssue in the last month. Did anyone? Maybe it's somehow solved and not a problem anymore.

Unfortunately just yesterday. If I'm at home and there aren't many devices around everything is fine. However in the situation yesterday (on a food market) with many people around I couldn't even unlock my phone and my BT headset lost it's connection. I had to power cycle the device to recover.

@bionade24
Copy link
Collaborator

I didn't experience this isssue in the last month. Did anyone? Maybe it's somehow solved and not a problem anymore.

Unfortunately just yesterday. If I'm at home and there aren't many devices around everything is fine. However in the situation yesterday (on a food market) with many people around I couldn't even unlock my phone and my BT headset lost it's connection. I had to power cycle the device to recover.

:( I thought about how to possibly debug this and my idea was to run valgrind on contrac and statefs for 24 hours, saving the big log on the NAS mounted via NFS or SMB. But if you need lots of phones around you to reproduce this, it's hard to do it. @llewelld

@dimpflmoser Are you on 3.4 or already on 4.0? Because 4.0 removes statefs, which according to above, is the problematic program taking all CPU load.

@dimpflmoser
Copy link

Are you on 3.4 or already on 4.0? Because 4.0 removes statefs, which according to above, is the problematic program taking all CPU load.

4.0.1.48 XA2+

@bionade24
Copy link
Collaborator

Are you on 3.4 or already on 4.0? Because 4.0 removes statefs, which according to above, is the problematic program taking all CPU load.

4.0.1.48 XA2+

If you ever have the chance to ssh into your device or open a terminal and look what application actually is taking all the CPU load, that would be super nice.

I've noticed something strange: When I have this app running and scanning active, sometimes the whole Sailfish UI becomes unresponsive. I managed to catch it in the act and it seems like statefs was using 100% CPU. I'm using an Xperia X Compact, did anyone else have a similar issue? Seems to mostly happen in crowded places like public transport.

@llewelld So we can exclude statefs from roots of the problem, can't we? Or is it already clear that the actualy problem is the permanent device scanning in the Bluetooth settings?

@bionade24
Copy link
Collaborator

@dimpflmoser You may want to try to explicitly disable the search for devices in the Bluetooth Settings (Pull down) when leaving home and see if you still get insane loads.

@dimpflmoser
Copy link

If you ever have the chance to ssh into your device or open a terminal and look what application actually is taking all the CPU load, that would be super nice.

You mean when the phone becomes unresponsive? Well this will probably be hard as the phone is unresponsive. :-) Next time it becomes less responsive I'll try to open fingerterm/toeterm, start htop and create a snapshot. Would a snapshot of Crest (with the option 'Show all processes' also help? Well just checked Crest and its values for CPU load are rather weird, so one more app that got mixed up by 4.0.1

@bionade24
Copy link
Collaborator

If you ever have the chance to ssh into your device or open a terminal and look what application actually is taking all the CPU load, that would be super nice.

You mean when the phone becomes unresponsive? Well this will probably be hard as the phone is unresponsive. :-) Next time it becomes less responsive I'll try to open fingerterm/toeterm, start htop and create a snapshot. Would a snapshot of Crest (with the option 'Show all processes' also help? Well just checked Crest and its values for CPU load are rather weird, so one more app that got mixed up by 4.0.1

Yeah, no matter how you do it, but an ssh connection with top open would the most lightweight. But try to always explicitly disable the search for BT devices from now on, maybe that already solves the problem, though I never experienced this before I used contrac.

@dimpflmoser
Copy link

You may want to try to explicitly disable the search for devices in the Bluetooth Settings (Pull down) when leaving home and see if you still get insane loads.

That doesn't seem to do anything while Contrac's 'Scan and send active' is set.

@Matzt
Copy link

Matzt commented Mar 1, 2021

I also do have that problem and IMHO is currently the biggest problem of contrac. I tried to try a few things in the last days but as Dimpflmoser pointed out it's really hard to troubleshoot an unresponsive device. My impression is (like others mentioned before) that some service can't handle the enormous number of found bluetooth devices (hundreds if not thousands) and at some point just freezes. I also have the impression that it doesn't matter if there are a lot of devices currently nearby or if over a long period of time many devices have been found (sometimes my Phone freezes even if not many active devices are near by but contrac has been running for a a few days). I found out that the list of found devices is cleared only when restarting the phone (toggling scaning in contrac and switching bluetooth on and off don't clear the list) but devices can be cleared in the settings by tapping them long and selecting "forget device" (or similar, German version is "Gerät vergessen"). If this option is available at the bluetooth api (which I don't know and don't have the time to investigate) it could be a solution to make contrac clear all devices besides the coupled ones every once in a while.

@bionade24
Copy link
Collaborator

bionade24 commented Mar 1, 2021

I also do have that problem and IMHO is currently the biggest problem of contrac. I tried to try a few things in the last days but as Dimpflmoser pointed out it's really hard to troubleshoot an unresponsive device.

A suggestion for now: Create a systemd timer which periodically restarts bluetooth and contracd.

@bionade24
Copy link
Collaborator

@llewelld In bluetoothctl there is an option to set a UUID filter. Are we alredy doing that and could this potentially help resolving this issue?

@dimpflmoser
Copy link

@llewelld In bluetoothctl there is an option to set a UUID filter. Are we alredy doing that and could this potentially help resolving this issue?

I'm wondering if it isn't enough to just regularly remove the devices in the list that are just listed with a name of its MAC address?

Such a command could look like this (requiring 'real' bash shell):

bluetoothctl devices | \
  while read MYDEV MYMAC MYNAME
  do
    if echo $MYNAME | grep -q "^\([A-Fa-f0-9]\{2\}-\)\{5\}\([A-Fa-f0-9]\{2\}\)$"
    then
      echo removing $MYMAC
      bluetoothctl remove $MYMAC
    fi
done

@dimpflmoser
Copy link

Here's some script that could permanently be run on console (as root).

I tested it last time I went to our central food marked that always crowded my phone that I had to reboot by long-press of the power key. With the key everything was fine.

However I realised that several keys reenter the list if the other phone is still around within 5 or 10 minutes.

I'm wondering if deleting those keys too quickly, does this stop Contrac from registering the newly deleted keys?

Next step would be to launch this script as a one-shot timer at boot time and that each iteration sets a new one-shot timer.

#!/bin/bash
sleepTime=60
while /bin/true;
do
   MYCOUNT=$(bluetoothctl devices | grep "\([A-Fa-f0-9]\{2\}-\)\{5\}\([A-Fa-f0-9]\{2\}\)$" |wc -l)
   echo Got $MYCOUNT
   if [ $MYCOUNT -gt 30 -a $sleepTime -gt 30 ]; 
   then
      echo reduce wait time; 
      let sleepTime/=2
   elif [ $MYCOUNT -lt 10 -a $sleepTime -lt 480 ]
   then
      echo increase wait time; 
      let sleepTime*=2
   fi

   bluetoothctl devices | \
      while read MYDEV MYMAC MYNAME
      do
         if echo $MYNAME | grep -q "^\([A-Fa-f0-9]\{2\}-\)\{5\}\([A-Fa-f0-9]\{2\}\)$"
         then
            echo removing $MYMAC
            bluetoothctl remove $MYMAC
         fi
      done

   echo sleeping $sleepTime seconds
   sleep $sleepTime
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants