I have a webpage that retrieves the GPS positions of buses, and display those in a map. It retrieves the positions once every 60 seconds through a loop like this:
function startLinhaLoop() {
if (!timer) {
loopLinha();
timer = setInterval(function() {loopLinha()}, 60000);
}
}
It works perfectly, you can see it working here.
I put the whole thing in an app for android, that I use regularly. One of its features is that, if the screen of the phone is off, it speaks how long the 3 closest buses will take to arrive. So, once each 60 seconds, you hear "Buses in x, y, and z seconds". The web version also speaks if the page is not active.
This app always worked perfectly, as the webpage. But in the last two months (after I updated Android Studio) it began to fail (no idea why): the loop takes much longer than 60 secs, and it is even irregular. It speaks now, then 3 minutes later, then 8, then 2, then 12... I have tried to see what happens, and the script is not getting stalled, nor waiting for a download (the download has a timeout
). It is simply like instead of timeout 60000
it was timeout random
.
But the really strange phenomena happens when I try to debug the app: as soon as I connect adb
wireless and begin looking at adb logcat
, the timer
works perfectly. I stop adb
server, and the timer goes crazy again. Connect, fine. Disconnect, crazy... It is like the timer
knows that I am looking to it. A Schrodinger timer. :) During all the time, the wifi is connected and the phone makes noises when receiving whatsapp or whatever, so internet is fully active always.
I know that this question is not very specific and kind of vague (sorry for that), but maybe someone has heard of something like this before. Maybe this is a bug in some recent release of Android Studio?
BTW, I am working in a rooted Android 4.4 in a Galaxy Note 4. In my wife phone it works as expected.