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

Protection is not restarted after pause #2

Closed
ameshkov opened this issue Aug 24, 2015 · 47 comments
Closed

Protection is not restarted after pause #2

ameshkov opened this issue Aug 24, 2015 · 47 comments
Milestone

Comments

@ameshkov
Copy link
Member

Linked forum threads:
http://forum.adguard.com/showthread.php?4710-APP-specific-white-list&p=54420#post54420
http://forum.adguard.com/showthread.php?5929-Android-Adguard-1-2-1087-Randomly-closes-on-Galaxy-S6&p=54429#post54429

The problem is that we receive network change events too often thus we can't start protection when it is in process of stopping.

We should throttle start/stop events handling.

@TPS
Copy link
Contributor

TPS commented Aug 25, 2015

Re: AdguardTeam/AdguardForWindows#45 (comment)

Maybe this is the cause? I meant to investigate this more fully, but, if this solves it, I'm all for it. ☺

@ameshkov
Copy link
Member Author

Nope, Windows and Android versions are totally different.
Windows service and Android service are only sounds similar.

@TPS
Copy link
Contributor

TPS commented Aug 25, 2015

I meant, this issue is very specific to this fix, but, like the Windows issue, a general issue investigating this may be appropriate. Or it may be moot if this fix solves it completely.… ☺

@TPS
Copy link
Contributor

TPS commented Aug 25, 2015

Also, I'm having this issue in proxy mode, as I can't functionally use VPN mode. (Separate bug has been e-mailed a few days ago.)

@ameshkov
Copy link
Member Author

Hm, that's something new, protection is not restarted in proxy mode. It is specific to VPN mode - we need to restart it on every network reconnect.

Could you please tell me ID of the ticket with the description of that proxy mode bug?

@TPS
Copy link
Contributor

TPS commented Aug 25, 2015

I've no ticket for that bug, as I've only starting noticing it. The other, non-related VPN bug, I've @ least 2 ticket #s for, but I don't think you want them here.…

@ameshkov
Copy link
Member Author

Anyway, if these bugs are still present, it's better to have them here on github.
Maybe support has missed it and didn't pass to us devs?

@TPS
Copy link
Contributor

TPS commented Aug 25, 2015

Ok, #23 filed. I think that 1 is a hard problem. ;)

@TPS
Copy link
Contributor

TPS commented Aug 31, 2015

I have just filed RMZ-109-29725 with details of what happens when AdGuard doesn't stay restarted in proxy mode. What's peculiar to me is that (as I mentioned in the report), when AdGuard quits after restarting, the app acts as if I quit the app myself, because it doesn't automatically reactivate as I'm used to, otherwise.

@ameshkov
Copy link
Member Author

ameshkov commented Sep 1, 2015

Thank you, got the log file.

So, what do I see there:
13:16:??: Adguard process was killed by Android
13:16:09.785: Adguard process was restarted (we've detected Android's sticky restart)
13:16:09.967: Starting protection, preparing filters
13:16:12.879: It looks like you've tried to start protection from UI. App has ignored this command (because it is already in process)
13:16:15.843: Protection has started

@TPS
Copy link
Contributor

TPS commented Sep 2, 2015

Something's missed in between. The sequence as I saw it happen:

  1. Android kills it. (13:16:??)
  2. It restarts. (13:16:09.785 & 13:16:09.967)
    3. It dies completely. (This is why long delay before next step: I'm waiting to see if it'll restart on its own.)
  3. I open the app, but it doesn't startup on open. (13:16:12.879)
  4. I activate via the Big Button, & now everything's fine. (13:16:15.843)

Almost every other time (maybe 5× more often than above), I see just steps 1 & 2 cycle through every 3 or 4 hours, but, about once a day, I have the above sequence (which, mind you, is still better than AB+, which forces a device reboot every 3 to 4 hours!)

@ameshkov
Copy link
Member Author

ameshkov commented Sep 2, 2015

3 seconds is not a long delay.
Maybe you mean that it dies completely before step 2?

Anyway, that seems to be android problem. Do you have some kind of power management app or settings? Sometimes it's possible to whitelist the app there so Android wouldn't kill it so frequently.

@TPS
Copy link
Contributor

TPS commented Sep 3, 2015

No, the order as I mentioned is correct, but maybe the timestamps you mentioned don't reflect precisely. (I've misread the 1s you quoted — I certainly waited perhaps a minute or more before trying an app restart, & confirmed app wasn't running before via app info).

I don't have any automatic power management via app, only Android system's own (which I think I've set as max power/least power-saving as possible ). I've also whitelisted app everywhere I can find.

@ameshkov
Copy link
Member Author

ameshkov commented Sep 3, 2015

Then I am pretty sure the order from the log is correct, but with one addition - the app was not restarted by Android.

  1. Android kills the app and (as it's sticky) schedules restart.
  2. You wait for a minute, the app is not restarted.
  3. You open the app.
  4. Android finds that the app was scheduled for restart and instead of simply starting it - sends restart "Intent" to our service.

That's why in the log file it looks like the app was restarted by Android (as it should).

The problem here is that this behavior is normal, Android sometimes kills apps and restarts them in a some period of time, we can't control or influence this behavior.

The only thing you can do is change Android settings to make it less aggressive to background processes.

@TPS
Copy link
Contributor

TPS commented Sep 3, 2015

Hmm. Where does 1 change these settings?

@ameshkov
Copy link
Member Author

ameshkov commented Sep 3, 2015

For instance try disabling Battery saver (if you have 5.X)

@TPS
Copy link
Contributor

TPS commented Sep 3, 2015

Same 4.4 x86 tablet, so no 5.x Battery Saver.… The only option is for WiFi power, which is set only for Max Power/No Saving.

@ameshkov
Copy link
Member Author

ameshkov commented Sep 3, 2015

Have you disabled AG notification icon? Having this icon enabled improves app priority.

@TPS
Copy link
Contributor

TPS commented Sep 4, 2015

Nope, learned that the hard via previous apps, so I intentionally left the notification icon enabled.

@Revertron
Copy link

Found one unquestionable bug, fixed it. Added some new workarounds for network changes and slow protection starts & stops. Needs thorough testing.
These new changes can fix all such issues, including #36.

@TPS
Copy link
Contributor

TPS commented Sep 4, 2015

@Revertron Ready & willing tester here.… How do I get hold of this version?

@Revertron
Copy link

@TPS You can get it here: https://cloud.jamm.me/index.php/s/50hYBtuQRHU72uD

@TPS
Copy link
Contributor

TPS commented Sep 4, 2015

Installed & using; of course, will need time to see how it behaves. (Did file 1 minor note in separate issue.) Thanks, @Revertron!

@TPS
Copy link
Contributor

TPS commented Sep 7, 2015

@Revertron This build is far less stable than the 1 from from #23 that I've been using 'til this point, which is about the same as the current 2.x release for me. It crashes every 15 to 30 minutes when actively web browsing (not with any other activity, curiously — just app updating, e-mail syncing, &c, stay working just fine) but generally restarts more quickly. Still, every 10 or 15 crashes, it doesn't restart timely at all, so I'm forced to manually start via the widget or app itself.

I'll send a bug report next time this happens, & note it here.

@ameshkov ameshkov reopened this Oct 5, 2015
@Revertron
Copy link

Fixed it yet again.

@TPS
Copy link
Contributor

TPS commented Oct 26, 2015

@ameshkov @Revertron I think this VPN-mode bug is back in Amazon .231, but only when device is in standby/screen-off. (I can't find the separate bug I thought was filed specifically about this?) I think this is also @ the root of AdguardTeam/AdguardFilters#869 & AdguardTeam/AdguardFilters#870, because they manifest in this state.

Ticket# OXG-496-68436

@ameshkov
Copy link
Member Author

@TPS
How long has it been since you've installed CM?
Have you added Adguard to CM's exceptions? Such cleaners are often kill AG process (as it seems to be rather heavy in battery usage stats)

@TPS
Copy link
Contributor

TPS commented Oct 27, 2015

I've had CM since long before AG, & have added AdGuard to CM's exceptions everyplace, even the AV (both internal & the separate CM AV app), as well as Greenify's. I reasonably sure neither of those is culprit here.

@TPS
Copy link
Contributor

TPS commented Oct 28, 2015

I've had an idea.… I'm going to try pref.vpn.disable.pause ✅ tonight & see if that makes a difference.… I've observed something that looks like a timing issue, & I hope this resolves it. Does this same pref work with the equivalent function for proxy?

Nope, no go.… Is there any way AdGuard can appear in [Android System Menu] » [Wireless & Networks] » [More] » [VPN] » [Vertical … Menu] » {Always On} (obscure, right? 😉) to force all connections to work only when VPN is active? Like, when proxy is down, most connections fail.…

@ameshkov
Copy link
Member Author

I don't think it could help. Do you know how extract LogCat logs? If you can do it for us I'll see there why Adguard process is killed.

@ameshkov
Copy link
Member Author

Here is an instruction: http://forum.xda-developers.com/showthread.php?t=1726238
Just get the log right after you face this problem again.

Also please leave default logging level in Adguard.

@TPS
Copy link
Contributor

TPS commented Oct 30, 2015

I'll use 1 of the logcat apps & report back. Thanks for the link!

Update: On Android 4.1+, these methods all require rooting or an external PC to get the whole system logcat. I'm not setup for either 1, so logcat will have to wait 'til I get my new laptop. (Hopefully, 1st week of December.) 🙏

@TPS
Copy link
Contributor

TPS commented Nov 3, 2015

I think 1 thing I'm seeing that, if AdGuard VPN doesn't come up (delays for some reason) by the time the connection is otherwise ready, foreground app & syncing will use connection anyway, including any of the above that download ads opportunisticly when a live internet connection is detected, like CM family of apps. 😞

Is there a way to minimize this delay? (Not quite same as disable.pause …) I agree there's the related problem of Android killing it, but that I can't help with (I think) until new laptop.…

@ameshkov
Copy link
Member Author

ameshkov commented Nov 3, 2015

@TPS it depends on the time when Android notifies Adguard that network is available. Unfortunately there can be a significant delay (up to 5-10 seconds). Second issue: all these apps are also listening to that event and could be notified before AG.

@TPS
Copy link
Contributor

TPS commented Nov 4, 2015

@ameshkov Is there an earlier event that AG could be listening for to give it a bit of an edge? Or a way to lock/block/disable the connection until it's ready to filter?

@ameshkov
Copy link
Member Author

ameshkov commented Nov 5, 2015

@ameshkov Is there an earlier event that AG could be listening for to give it a bit of an edge? Or a way to lock/block/disable the connection until it's ready to filter?

Using other events won't solve the problem we are solving with VPN restart. We should start VPN when connection is fully established so that the network routes are stable.

@vozersky
Copy link
Member

vozersky commented Aug 16, 2016

id 1373719, the same issue with both Adguard 2.6 and 2.7 on Huawei device
process is not killed, but Adguard doesn't restart protection after connecting to network
please advise

@ameshkov
Copy link
Member Author

@vozersky it'd be better if you file a separate bug report on that issue.

@vozersky
Copy link
Member

@ameshkov
done: #758

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

No branches or pull requests

4 participants