JavaJens / TextSecure

A secure text messaging application for Android.
GNU General Public License v3.0
72 stars 9 forks source link

Huge message delays #60

Open mjtorn opened 8 years ago

mjtorn commented 8 years ago

Hi!

I recently downgraded/switched from Signal (off of Google Play) to the Jolla Edition, version 3.3.1, and noticed messages are sometimes delayed.

Since Moxie doesn't like different builds (open-source cat-herding can be a pain) I'll ask here first: is there any kind of wake-up delay interval thingies for polling messages? Do the sockets get closed and not often reopened?

Anything that might explain having only one tick on sending messages and not receiving anything, until three hours' worth of messages come in as a burst?

The missus and I would really love to get off Whatsapp and I wanted to get off Google so this fork is pretty much the only hope we have currently.

Thanks!

JavaJens commented 8 years ago

You can try to get a debug log. There shouldn't be any artificial delay. Iirc there might be an exponential backoff if there are connection problems.

mjtorn commented 8 years ago

https://gist.github.com/anonymous/68e8573064d73ec6cafb

I was kind of hoping for more...

Should it log about websockets? Could it be made to? ;)

JavaJens commented 8 years ago

There is no log in there :wink:

I don't know if there is sth. special about Jolla. Maybe try adb?

mjtorn commented 8 years ago

What's adb?

Yeah, unfortunately I don't have any contact to whomever built the Jolla Edition, but afaik it's 3.3.1 from this fork with no changes.

relyt29 commented 8 years ago

I can confirm that occasionally I also get long delays between messages. I think it has something to do with the screen being off, as it only happens when the app is in the background. Also on version 3.3.1 - I need to update and see if that fixes it, it may just be a bug in 3.3.1 that got fixed in a later commit

JavaJens commented 8 years ago

adb http://developer.android.com/tools/help/adb.html

The most likely assumption that I can make is that some power savings mode kicks in. Could that be the case?

mjtorn commented 8 years ago

Oh man.. That ADB thing looks like quite the hurdle, I'll have to see about whether or not that's worth it, really, when simple "lost the socket" and "could not reconnect, backing off for $t seconds" debug logging could cut it.

Very little sample data on this, but the messages worked pretty fast over wifi, so maybe something like the exponential backoff theory could be true.

Besides that, maybe I'll wish for a new build to hit the Jolla store for xmas ;)

JavaJens commented 8 years ago

Usually the log from the menu should suffice, maybe just try again?

mjtorn commented 8 years ago

Sorry @JavaJens but I have to ask you to explain this to me like I'm five ;) The gist above is the debug log, so you probably don't mean that, right?

If you mean a log from a menu in ADB, I'll need to have ADB running first, which is probably a huge hassle. This especially as Jolla's OS, SailfishOS, is a Linux with Alien Dalvik for Android support, so who knows how it'll work out.

mjtorn commented 8 years ago

FWIW I found some online presence for the guy buildling this for us, so I pinged him in the only way I could find.

ton-io commented 8 years ago

@mjtorn iam using 3.8.1 from this repository on my blackberry and i dont have any delays. Have you tried compiling the latest version from javajens?

mjtorn commented 8 years ago

@ton-io that's good news! Blackberry is not Jolla, of course, but that gives me hope.

I have not tried compiling it, because I have no idea about how to make it look like @llelectronics build of it, and I don't want to confuse my phone by installing different versions.

It's idealistic to expect things like this to Just Work but there is a pain threshold in going in deep for debugging, so I'd rather just wait for the next "official" release and get back to this issue after that.

And still hoping there'd be debug logging about the state of sockets and maybe powersaving, as it sounds like adb on sailfish is not easy.

JavaJens commented 8 years ago

@mjtorn yes, I mean the gist. Usually this contains all debug information you get through adb without the hassle. If this doesn't work, I fear adb is the only way.

mjtorn commented 8 years ago

Well, there's nothing there in the debug log. Like if I try to access my contacts, I don't see any (not sure if this warrants a new issue, as this happened with upstream Signal as well and obviously Jolla/Sailfish is completely unsupported) there's nothing about "no contacts found" in the debug log either.

Let's keep this issue open and see if this works at all and then I may consider adb.

(I really wish people weren't afraid of extreme logging settings and advanced options)

llelectronics commented 8 years ago

For contacts did you check if it is allowed for android apps to have access to contacts? If it isn't that would explain this issue.

mimi89999 commented 8 years ago

For contacts: Probably related https://github.com/WhisperSystems/Signal-Android/issues/4943

mjtorn commented 8 years ago

@llelectronics it's not that. It's on by default and if I turn it off, Signal crashes without any greater ceremony or grace.

https://gist.github.com/anonymous/ae6fc99138a7818acf6b

Not sure at all what's happening with android.media.AudioAttributes$Builder but yeah. It's not about the contacts access.

mjtorn commented 8 years ago

Maybe it could be related to upstream issues, but I did see the contacts list for a while with this Jolla Edition / JavaJens build, and then it vanished and never returned.

mimi89999 commented 8 years ago

@JavaJens There will be huge message delays in android 6. Please look at: https://developer.android.com/training/monitoring-device-state/doze-standby.html :-(

mjtorn commented 8 years ago

Hmh, but with wifi, things seem to work, so despite how the missus might have configured or updated, I still like to think there's something screwy with mobile internet and websockets...

We'll be looking into her Android version and that URL I'm sure, thanks!

mjtorn commented 8 years ago

Note: Google Play policies prohibit apps from requesting direct exemption from Power Management features in Android 6.0+ (Doze and App Standby) unless the core function of the app is adversely affected.

So, stupid question, @mimi89999 but isn't a messager exactly the kind of thing whose core is adversely affected? Therefore these apps should be exempt, yes?

I just heard she's sometimes wondered why she hasn't received Whatsapp messages either, and after digging her phone from her purse, she gets a burst of messages.

But even that does not explain why sending me messages (while I'm on mobile internet) from a wifi (eg. my place) do not arrive.

So it still could be something about mobile internet and websockets on my part :(

mimi89999 commented 8 years ago

@mjtorn capture du 2015-12-26 21-06-02

mimi89999 commented 8 years ago

@mjtorn "Note: Google Play policies prohibit apps from requesting direct exemption from Power Management features in Android 6.0+ (Doze and App Standby) unless the core function of the app is adversely affected." "Google Play policies" only apply to apps published in the Play Store...

JavaJens commented 8 years ago

@mjtorn there is heavy logging in the app, but I'm afraid this is a limitation of Jolla.

mjtorn commented 8 years ago

@mimi89999 Yeah, saw that note as well, but didn't read through it well enough to worry about whether or not IM apps are prohibited or allowed.

@JavaJens thanks for the info, at least that's something I can bring up somewhere, maybe, to ask why there's nothing sticking to the debug log.

mjtorn commented 8 years ago

I snuck the debug log off of her normal Signal installation and it's all a lot more verbose

https://gist.github.com/anonymous/625d7ed1bd9a14aa273f

Interesting that the mainstream client would use websockets? Am I interpreting something wrong here?

mimi89999 commented 8 years ago

@mjtorn If it was using WebSockets, then there would be wss:// somewhere in the log...

Edit: Sorry, there is "wss://" in line 296. I was writing non-sense :-(

mimi89999 commented 8 years ago

@mjtorn I found a WebSocket echo test: https://www.websocket.org/echo.html

JavaJens commented 8 years ago

@mjtorn The regular client uses websockets while the app is open. This is used to prevent the delay introduced by GCM. But as battery usage increases with websockets, the socket is closed when the app is in the background.

In her log you see a timeout exception reaching the server, maybe similar things are happening to you?

mjtorn commented 8 years ago

@mimi89999 Testing that with the browser over 3G works.

@JavaJens The timestamps in her log are mainly early morning, so probably the app was in the background at the time. Well, I need to figure out how to enable logging here so I can check if I have wss:// somewhere in the log that I just can't see.

But that cleared why there were mentions of websockets, at least :)

PS. Sent a message to her just now and it worked just fine. She's on 4G and when I switched to 3G, I got stuck with only one tick. Switching back to WLAN pushed out the messages.

Going to try to look at /opt/alien/system/bin/logcat at some point. Too bad I can't be in on my phone over 3G, that local access isn't as good as ssh, and that it doesn't provide me with timestamps or a clear idea of which app is doing what :D But maybe something will stick.

ivilata commented 8 years ago

I'm having the same problems with version 3.9.1. I have no idea on how websockets work in Signal but, could it be that the server code has bad backoff behaviour in the case of websockets?

I'll take more careful observation on when the problem happens.

JavaJens commented 8 years ago

@ivilata Could you try to create a debug log? The most probable cause of message delays is the system shutting down connections after the a while (Power-save features) If you open the app and the message doesn't arrive immediately, then there is some other issue

ivilata commented 8 years ago

@JavaJens, the log under Settings / Advanced / Submit debug log doesn't contain lines under /dev/log/main. :(

In the last two occasions that I've received delayed group messages, they have arrived exactly 3 hours after the last one has been sent. I can assure that in the first case, the phone was already in Wi-Fi before the messages were sent, and it remained in Wi-Fi at the same place until the messages arrived 3 hours later.

Is there any other test I can perform? Thanks!

mjtorn commented 7 years ago

FWIW I still see long lags sometimes, though it's been ages since I switched to the WhisperFish client :/ So it might be that it's a server-side thing.