Author Topic: No IMAP only sync after reboot on Marshmallow, android 6  (Read 15993 times)

das1996

  • Newbie
  • *
  • Posts: 26
No IMAP only sync after reboot on Marshmallow, android 6
« on: March 12, 2016, 04:05:52 am »
Hello.

Have aquamail setup up to view 2 accounts, 1 folder each.  Imap works fine if I open the app at least once after reboot.

However unopened, it doesn't appear to receive after rebooting the phone.

I've messed with the various keep alive options and network settings but can't seem to make this happen.

Note, I'm not using any polling or other timed sync.  All I want is imap functionality only.

Thoughts, suggestions?

Thanks!
« Last Edit: March 12, 2016, 08:37:47 pm by das1996 »

StR

  • Hero Member
  • *****
  • Posts: 1558
Re: No IMAP only sync after reboot
« Reply #1 on: March 12, 2016, 05:39:25 am »
From you implicit description,  I assume you enabled PUSH.
You want to enable scheduled check in the background.
Push only keeps the connection alive after the connection is opened.Scheduled sync does that.

(BTW, that all is  done via IMAP)

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot
« Reply #2 on: March 12, 2016, 06:41:18 am »
Yes, push is enabled.

What settings do I choose under the scheduled sync once it's enabled?

Specifically for mail check interval, custom check interval, and time reference point?

As you point out, the connection needs to first be opened after a reboot. 

I've already tried the scheduled sync with

mail check interval : 24 hours
custom check interval: not specific
time reference point: 12:00 am
settle in delay: 15 sec
Only screen is off: unchecked
wifi in sleep mode : unchecked

Imap is checked in the next section.

StR

  • Hero Member
  • *****
  • Posts: 1558
Re: No IMAP only sync after reboot
« Reply #3 on: March 12, 2016, 09:14:37 am »
Quote
mail check interval : 24 hours
To me, the combination of this with PUSH enabled sounds like: "I don't want my mail checked, but I'd like to know immediately when it arrives". While, depending on the server, it may work, but it seems to me unstable, or at the very least, unreasonable. (I will avoid boring you with the technical details, especially since I am too sleepy at the moment to describe them.)

If you want immediate information about the arrival of messages (hence the PUSH) at all times, I'd set the mail check interval to 15 or 30 minutes and keep the PUSH enabled.

As for other parameters, in Aquamail, the default values are pretty reasonable, especially for people who do not have experience with fine-tuning an e-mail app. In your case, (if you really want the immediate notification about message arrival), I would start from all the default settings and just enable PUSH (for details on that and other topics, please see the FAQ http://www.aqua-mail.com/?page_id=227 ).
But be aware that PUSH (compared to just scheduled checking at some reasonable interval, say 15-30 min.) will increase your battery and data consumption.

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot
« Reply #4 on: March 12, 2016, 10:32:07 am »
I've been using k9 for years, and more recently k-@ mail.  Both of those allowed me to configure the client such that no periodic syncing was needed, only push email (imap) was configured and worked.  In fact, the whole reason for going to k9 was because the stock android email clients offered very little configuration. 

This is the type of functionality I'd like to get out of aquamail. 

I've configured countless email clients, so generally have a good idea of the workings behind the scene.  Aquamail gives ultra fine granular control of many aspects of an email client.  This was part of the reason for switching over.

I did enable scheduled sync with a 24 hours mail check interval.  This didn't work.  It failed to retrieve a message that was sent as the phone was rebooting.

Assuming it did work, it seems like enabling periodic sync is more a bandaid for a simple function such as "enabled at boot".  I don't want it to check every xx minutes, rather I want emails delivered instantly as they're 'pushed'. 

I wonder if the fact that device is on android 6/marshmallow is somehow affecting all of this.

I understand push may cost more in terms of battery or data, I'm ok with this (to an extent).

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot
« Reply #5 on: March 12, 2016, 10:50:24 am »
I have a domain on a shared server at mddhosting.com (s3.supportedns.com is the mail server, port 993, encrypted connection).

Appears to be dovecot.

Gmail might be handled differently as it may involve GCM.

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot
« Reply #6 on: March 12, 2016, 11:53:44 am »
I think I found the problem.  I used titaniumbackup to duplicate the settings to a 5.0.1 phone.  Rebooted.  App started properly on it's own as expected with only imap enabled.

So, appears to have something to do with the way marshmallow handles app initialization at phone boot up. 

Under LP, in settings, apps, aquamail, under permissions there is "run at startup" present.

Marshmallow won't show me the full list of permissions, just showing  calendar, contact storage permissions.

------------------

Edit:  settings, developer options, running services.  After boot, no entry for aquamail.  Refresh running services after running the app now includes it, along with 2 services (syncstart being one of them).




« Last Edit: March 12, 2016, 12:05:39 pm by das1996 »

StR

  • Hero Member
  • *****
  • Posts: 1558
Re: No IMAP only sync after reboot
« Reply #7 on: March 12, 2016, 07:38:13 pm »
It might be indeed that in your case, something is preventing Aquamail from starting (or starting properly). I don't know that part.
If that's the problem, then setting syncing would not matter. You need to find the reason why Aquamail does not start upon booting. Sorry, I don't use Marshmallow, and don't know all its intricacies.


As for setting periodic sync, from what I know (and Kostya, Aquamail's developer might shed more light on this), some IMAP servers might not maintain the connection beyond certain period of time (30 min? 1 hour?).
I don't remember for sure, and I don't feel like search for it now, - it might be that IMAP IDLE (aka PUSH) specifications do not require the server to maintain the connection indefinitely.
So, even if the setting for PUSH in Aquamail is set to a long time, the server may drop that connection. That's why it just makes sense that Aquamail starts the connection every so often (and not once a day). And, of course, when you switch to a difference network (Wi-Fi vs mobile network) you connection can also drop (as you change the IP address).
That's the reason why it makes sense to do periodic sync. That's my view on it. I might be overly conservative. But in any case, - I do not see any downside for periodic sync, and I don't see any rational why you do not want that to happen.

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot
« Reply #8 on: March 12, 2016, 08:37:02 pm »
One issue at a time.  Your point on periodic sync is valid.  Once this startup issue has been resolved then I can focus on whether or not the server in use requires the periodic sync enabled.

I can't say I've been overly impressed with MM.  Sure it brings some new features, but also breaks a number of things - IE, if portable storage is used rather than adopted, apps can no longer be stored on the sd.  In the case here, it forces the developer to in essence re-invent the wheel to comply with the new OS requirements otherwise things don't work right.

The phone in question is the moto x pure (style).  I'd gladly go back to lollipop but there's few custom rom or kernel options available.  Given the nature of motorola's almost stock android UI, I'd prefer to stay stock based rather than going with something aosp. These days most development has been MM based.

I'll await to see the developer's comments. 

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: No IMAP only sync after reboot on Marshmallow, android 6
« Reply #9 on: March 13, 2016, 04:01:11 pm »
Re: I can't say I've been overly impressed with MM.  Sure it brings some new features, but also breaks a number of things

Just wait for N, they're continuing down same path.

Re: Gmail might be handled differently as it may involve GCM.

And they're having widespread issues where it falls behind server state by hours. I'm seeing it on my Nexus 6P too.

---

And the issue at hand.

In general, I don't recommend turning off scheduled sync (or making it so infrequent) even if push is enabled.

- Scheduled checks act as a safety net for push code

- Typically you will only have push enabled for some of the folders -- and so scheduled mail checks will get the rest

---

Now that being said... Push should start after a reboot.

Does your phone have some sort of "fast reboot" feature, where the device doesn't really reboot, it just kills all apps and restarts the launcher? HTC used to do this, and it was even enabled by default.

With "fast reboot", the system does not send the usual "a reboot has completed" broadcast to the apps.

So if you do, please try turning that off.

---

And ultimately, I'd like to see a debug log capturing the issue (please see the link in my signature).

You will want to enable logging, then reboot the phone, and wait for 3-5 minutes before starting up the app's UI (I assume that push will start up at that point).
Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot on Marshmallow, android 6
« Reply #10 on: March 13, 2016, 06:53:02 pm »
@Kostya

Re: fast reboot.  I'm familiar with this restart method and no, it is not in use on the moto x pure. All reboots are complete.

Raw log as requested is available @ http://pastebin.com/ixgGXnLp

I've obfuscated any and all personal identifying information for privacy reasons.  Hopefully it sheds some light as to what's happening after the reboot.


Edit:  From my uneducated log reading, I think this "conn. null" entry that appears several times before the app is actually launched may have something to do with it.

Further down, after the app is launched, around line 471, there's no longer a null after conn.

-------------

Unrelated, re MM:

Among other things mentioned I'm finding sleep patterns to be less than desirable.  Phone loses ~8% battery over night with airplane mode on.  I'm still tweaking various things, but almost seems like it does better with wifi on.  I have a feeling it may be wise to just downgrade to 5.1.1 and call it a day (assuming that works correctly and sleeps well).
« Last Edit: March 13, 2016, 07:11:44 pm by das1996 »

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: No IMAP only sync after reboot on Marshmallow, android 6
« Reply #11 on: March 13, 2016, 07:55:48 pm »
Thank you. You can delete the log from pastebin.com now if you wish.

Yes, the reboot is proper, not "fast".

2016.03.13 09:30:13.644

Android notifies the app that there is now a network connection

The app schedules an event for 15 seconds later (to actually start up push mail)

This event is not received.

I wonder if the device is in Doze mode (initially) after the reboot?

Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot on Marshmallow, android 6
« Reply #12 on: March 13, 2016, 08:01:12 pm »
In doze mode with the screen on? 

Reboot process goes something like this:

Reboot phone, unlock once the lock screen shows, then wait a min for it to settle.  Once settled, send a test message.

How are you determining the event is not received?

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: No IMAP only sync after reboot on Marshmallow, android 6
« Reply #13 on: March 13, 2016, 08:54:00 pm »
I just did same test on my Nexus 5x (6.0.1 stock), with your settings (scheduled sync off, push on).


2016.03.13 13:48:14.011 -0400   PushConnectivityReceiver   [][][][][] onReceive ConnectivityManager.CONNECTIVITY_ACTION: ni = [type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "Despotica", roaming: false, failover: false, isAvailable: true]
2016.03.13 13:48:14.012 -0400   PushConnectivityReceiver   [][][][][] Currently active network info: [type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "Despotica", roaming: false, failover: false, isAvailable: true]
2016.03.13 13:48:14.013 -0400   PushConnectivityReceiver   [][][][][] Scheduling the delayed alarm
2016.03.13 13:48:14.014 -0400   AlarmCompat_api19   setWindow: 0, 1457891299013 (2016-03-13 13:48:19) 5000, PendingIntent{4ea362b: android.os.BinderProxy@bab7e7a}
2016.03.13 13:48:19.045 -0400   PushConnectivityReceiver   onReceive: intent = Intent { act=org.kman.AquaMail.ACTION_CONNECTIVITY flg=0x10000014 cmp=org.kman.AquaMail/.core.PushConnectivityReceiver (has extras) }
2016.03.13 13:48:19.046 -0400   PushConnectivityReceiver   [][][][][] Starting the service to start watchers


This is the "delayed alarm" above.

In your log, the line where the app sets this alarm is present:

2016.03.13 13:48:14.013 -0400   PushConnectivityReceiver   [][][][][] Scheduling the delayed alarm
2016.03.13 13:48:14.014 -0400   AlarmCompat_api19   setWindow: 0, 1457891299013 (2016-03-13 13:48:19) 5000, PendingIntent{4ea362b: android.os.BinderProxy@bab7e7a}

but the alarm does not go off (does not trigger):

2016.03.13 13:48:19.045 -0400   PushConnectivityReceiver   onReceive: intent = Intent { act=org.kman.AquaMail.ACTION_CONNECTIVITY flg=0x10000014 cmp=org.kman.AquaMail/.core.PushConnectivityReceiver (has extras) }

Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

das1996

  • Newbie
  • *
  • Posts: 26
Re: No IMAP only sync after reboot on Marshmallow, android 6
« Reply #14 on: March 13, 2016, 10:29:10 pm »
I see what you mean.

I've got a few xposed modules running (gravitybox and amplified). I don't recall setting any entries for aqua in amplified.  I don't think there's any settings in gravitybox that would affect aquamail. 

Maybe there's some other glitch or corruption.  It'll be easy enough to do a factory reset and restore several apps at a time from titaniumbackup, reboot and test.