microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
7.63k stars 1.61k forks source link

Notifications get "stuck", turning Cloud Messaging on/off solves the problem #1671

Open VitalogyRS opened 2 years ago

VitalogyRS commented 2 years ago

Hello,

I have a Huawei P40Pro, standard ROM, right now EMUI 12.0.0 with latest updates (based on android 10).

As everyone else with a relatively new Huawei, notifications are complicated but microg works very well. But sometimes, notifications are "stuck" and don't arrive (either teams, whatspp) although the Cloud Messaging service shows connected. If I toggle off / on the option "Receive push notifications" under Cloud Messaging then the notifications appear all at once and keep working for a while.

When the notifications are in this status, even if I enter the app in question I don't receive the notifications but can see the badge in the app.

I can't really understand if something triggers this behaviour, anyone else seeing this?

I'm on the latest microg.

Thank you

serrj-sv commented 2 years ago

The problem here is that Huawei's power management system sometimes kills mcroG service (even if you enable "Battery optmization ignored"). You can check this in: Settings -> Battery-> App launch -> 3/4 dots menu -> Launch records. Here you can see that sometimes microG services core is restricted from auto-start:

image

The solution would be to manually allow microG autostart and work in background, but I cannot find it in "App launch" apps list:

image

mafs77 commented 2 years ago

Hi, I have a P40 lite and with latest version 0.0.24.214816 this as improved, and to me only happens during the night. I also disable WIFI and mobile data during this period. In the morning activating Wifi and mobile data doesn't re-enable microG Cloud Messaging, so turning it off and on solves the problem during the day.

VitalogyRS commented 2 years ago

The problem here is that Huawei's power management system sometimes kills mcroG service (even if you enable "Battery optmization ignored"). You can check this in: Settings -> Battery-> App launch -> 3/4 dots menu -> Launch records. Here you can see that sometimes microG services core is restricted from auto-start:

image

The solution would be to manually allow microG autostart and work in background, but I cannot find it in "App launch" apps list:

image

First, thanks for your reply.

Second, sorry, I should have been more clear on the configurations I have and should have said that all the optimizations are in place: AppLaunch v2 BatteryOptimizationv2

I've read all the forums and followed basically every suggestion I've seen but still this behaviour persists.

Thank you

VitalogyRS commented 2 years ago

Hello,

Got a chance to make a video showing what I mean (sorry for the blur, but the bold characters will help). So it begins by me entering Teams and you will notice bold characters, meaning I have unread messages. After that I close all apps, go to MicroG, Cloud Messaging and toggle off / on the option "Receive push notifications". And you'll notice a Teams notification appearing.

Thank you

https://user-images.githubusercontent.com/99566144/154044982-95b9f0d2-c75e-4817-bdd3-26cad40ceb09.mp4

mafs77 commented 2 years ago

Hello,

Got a chance to make a video showing what I mean (sorry for the blur, but the bold characters will help). So it begins by me entering Teams and you will notice bold characters, meaning I have unread messages. After that I close all apps, go to MicroG, Cloud Messaging and toggle off / on the option "Receive push notifications". And you'll notice a Teams notification appearing.

Thank you Example.mp4

Hello, I understand perfectly. I have/had that problem also, less now with the newer version. Check something please, open microG, Self-Check, "Permissions Granted" and "System". Do you have all boxes checked? Screenshot_20220215_110549

VitalogyRS commented 2 years ago

Iup, all options ticket (with the exception of the ones the official Huawei ROM doesn't support): Options

serrj-sv commented 2 years ago

@VitalogyRS try also reduce ping interval for push notifications: Cloud Messaging -> 3 dots -> Advanced -> change for all networks from default 5 min to 2 mins. then also try 60 sec if not helping. Note that it will likely affect battery.

VitalogyRS commented 2 years ago

@serrj-sv, already did, the video is with the settings at 60 seconds both on wifi and mobile

Thank you

serrj-sv commented 2 years ago

@VitalogyRS try also builds from here: https://github.com/jcchikikomori/GmsCoreHuawei this is microG fork optimized for Huawei phones with extra functionality (maps v2 api, nearby share)

VitalogyRS commented 2 years ago

@VitalogyRS try also builds from here: https://github.com/jcchikikomori/GmsCoreHuawei

I would try it but I can't seem to find the download section

serrj-sv commented 2 years ago

@VitalogyRS try also builds from here: https://github.com/jcchikikomori/GmsCoreHuawei

I would try it but I can't seem to find the download section

under "assets": https://github.com/jcchikikomori/GmsCoreHuawei/releases

VitalogyRS commented 2 years ago

@serrj-sv, thanks!

One question, I have to uninstall microg and all it's components, or just gmscore, do you know?

serrj-sv commented 2 years ago

just gmscore

👆

mafs77 commented 2 years ago

I'll give it a try also.

VitalogyRS commented 2 years ago

Ok, trying it. Let's see how it goes. 🤞

VitalogyRS commented 2 years ago

Ok, trying it. Let's see how it goes. 🤞

Well, the notifications still don't show even if I toggle the Receive push notifications option off / on. Guess I'll go back to microg

VitalogyRS commented 2 years ago

So... Went back to microg, latest version, and noticed that I was having the exact same problem as I did with GmsCoreHuawei, that is if I toggled the Receive push notifications option off / on the notifications didn't appear. Then I remembered: I read somewhere that earlier version of GmsCore were working better than the latest ones and my original posts were not with the latest version, was using v0.2.22.212658 at the time. I then read on the release notes of the next release (v0.2.23.214816) the following: Improve reconnecting logic

I'll test a bit longer with version v0.2.22.212658 to check if toggling the Receive push notifications option off / on does show the notifications and after I'm sure it does will upgrade to the next release, v0.2.23.214816, to try and figure out if something introduced on that release is the cause for the notification not being shown even when toggling the Receive push notifications option off / on

Thank you

ale5000-git commented 2 years ago

@VitalogyRS

Then I remembered: I read somewhere that earlier version of GmsCore were working better than the latest ones and my original posts were not with the latest version, was using v0.2.22.212658 at the time.

Most of the times it is just an impression, the latest version (which is v0.2.24.214816 and not v0.2.23.214816) should work better for notifications.

ale5000-git commented 2 years ago

@serrj-sv

@VitalogyRS try also builds from here: https://github.com/jcchikikomori/GmsCoreHuawei this is microG fork optimized for Huawei phones with extra functionality (maps v2 api, nearby share)

It isn't true, the only change that I know of (if I'm not wrong) is to fake device info that is now included also in offical microG. maps v2 api and nearby share are the same of offical microG.

VitalogyRS commented 2 years ago

@ale5000-git

Most of the times it is just an impression, the latest version (which is v0.2.24.214816 and not v0.2.23.214816) should work better for notifications.

That's what I'm testing, if it's just an impression. But I did notice what I mentioned, the latest build won't show missed notifications when toggling off/on the Receive push notifications option and this one did.

And I realize the latest build is v0.2.24.214816 but if my tests prove correct, moving to the next release v0.2.23.214816 instead of v0.2.24.214816 will allow me to understand in which version whatever I'm noticing was introduced.

Thank you

VitalogyRS commented 2 years ago

Hello everyone,

I can now confirm without any doubt that the v0.2.22.212658 version does behave as I mentioned, if by any chance a notification is missed, toggling off/on the Receive push notifications option shows the missed notifications. But in general the notifications work OK, sometimes are not immediate but do appear. Will upgrade to v0.2.23.214816 (not the latest release) and see if in that one the behaviour is the same. But this version (v0.2.22.212658) works very well on a Huawei P40Pro without GMS. Will update with the results of version v0.2.23.214816

Thank you

VitalogyRS commented 2 years ago

Hello everyone,

Just happened a test case scenario, received a Teams message on my laptop but not on my phone. Toggling off/on the Receive push notifications option shows the missed notifications using version v0.2.23.214816. Will test a bit more and post the results.

Thank you

ale5000-git commented 2 years ago

Note that the difference of 0.2.23 vs 0.2.24 regarding notifications is none.

VitalogyRS commented 2 years ago

Thanks @ale5000-git for your comment

I haven't said anything in the last few days but it does feel that version v0.2.22.212658 had less "stuck notifications" than v0.2.23.214816. Im other words it feels like I'm missing more notifications in 0.2.23 than in 0.2.22.

Would like to go back to 0.2.22 to test again but there's no easy way to re-register all the apps besides reinstalling them, is there?

Thank you

VitalogyRS commented 2 years ago

Hello,

I now wonder if I kinda missed the obvious: notifications may be failing because the status turns to disconnected and never connects again unless I toggle off / on the option to Receive push notifications

Screenshot_20220228_115103_com.google.android.gms.jpg

Would a log of the current status help?

Thank you

mire777 commented 2 years ago

Hello,

I now wonder if I kinda missed the obvious: notifications may be failing because the status turns to disconnected and never connects again unless I toggle off / on the option to Receive push notifications

Screenshot_20220228_115103_com.google.android.gms.jpg

Would a log of the current status help?

Thank you

Same happen to me. After some time status turns to disconnected, so i must go in settings again and turn ON/OFF cloud messaging, to be able to receive notfications again.. You don't even know when that will happen, you must check offten. Very frustrating..

On Huawei P Smart 2021, workaround is to uninstall "POWER GENIE".. I guess it's the same on P40. "POWER GENIE" kills "GMS CORE", and this is the reason you won't receive notifications after some time..

I tried that.. And it works..

But without "POWER GENIE" i noticed lag in scrolling.. System is unstable. Because Power Genie is not that only reduces battery consumption (by controling wake locks), it also effect CPU and other things, so it ensures that your phone usage is optimal..

Maybe developer could find some other way for GMS CORE to stay active in background? Uninstalling Power Genie is not solution for our Phones..

EDIT: If MicroG could restart cloud messaging, or press ON/OFF itself, lets say every 30min, problem would be solved.. Maybe some modified MicroG for our Phone?

VitalogyRS commented 2 years ago

Same happen to me. After some time status turns to disconnected, so i must go in settings again and turn ON/OFF cloud messaging, to be able to receive notfications again.. You don't even know when that will happen, you must check offten. Very frustrating..

On Huawei P Smart 2021, workaround is to uninstall "POWER GENIE".. I guess it's the same on P40. "POWER GENIE" kills "GMS CORE", and this is the reason you won't receive notifications after some time..

I tried that.. And it works..

But without "POWER GENIE" i noticed lag in scrolling.. System is unstable. Because Power Genie is not that only reduces battery consumption (by controling wake locks), it also effect CPU and other things, so it ensures that your phone usage is optimal..

Maybe developer could find some other way for GMS CORE to stay active in background? Uninstalling Power Genie is not solution for our Phones..

Hello,

I may be wrong but I believe the P40Pro doesn't have PowerGenie.

Something else is probably causing this, the status turns to disconnected and it takes a while to get connected again (I'm now trying version 0.2.21, with version 0.2.23 the status stayed disconnected for more than 12 hours before automatically reconnecting)

Can anyone tell me what may cause the disconnection of the service considering the phone is not restarted and always has internet, wether wifi or mobile?

Thank you

mire777 commented 2 years ago

I may be wrong but I believe the P40Pro doesn't have PowerGenie.

Yes you have Power Genie - https://forum.xda-developers.com/t/powergenie.4104505/

Power Genie is what stops GmsCore from running. But i said uninstalling that would make Huawei phone unstable..

VitalogyRS commented 2 years ago

Yes you have Power Genie - https://forum.xda-developers.com/t/powergenie.4104505/

Power Genie is what stops GmsCore from running. But i said uninstalling that would make Huawei phone unstable..

Thanks, don't know why I was under the impression P40Pro didn't have it.

mire777 commented 2 years ago

Yes you have Power Genie - https://forum.xda-developers.com/t/powergenie.4104505/ Power Genie is what stops GmsCore from running. But i said uninstalling that would make Huawei phone unstable..

Thanks, don't know why I was under the impression P40Pro didn't have it.

You could try to uninstall Power Genie, and see what will happen, if you notice some lag, you can enable it again.

Link: https://forum.xda-developers.com/t/remove-powergenie-to-allow-background-apps-to-receive-push-notifications.3890409/

mafs77 commented 2 years ago

Seems that with EMUI 12 update it got worse. At least on my P40 lite using latest microg version.

mire777 commented 2 years ago

Seems that with EMUI 12 update it got worse. At least on my P40 lite using latest microg version.

Did you uninstall PowerGenie?

I dont know if this is problem with other phones.. But, on Huawei you must uninstall PowerGenie if you want that MicroG keeps running in background.. But it's not good for our Phones, because this service is not only responsible for reducing wake locks and killing background apps, it also reduces CPU usage. Without it, phone have lags..

Maybe some modified MicroG with notification in status bar could help keep it alive? If not, then some other app could restart Gms Core Cloud Messaging..

I tryed to do that with MacroDroid. I set task which opens MicroG Settings after 6 hours, and press ON/OFF itself. This works. I used it for 2 weeks without interruption in receiving notifications.

Only problem is --> you will see how MacroDroid starts MicroG Settings in foreground, and presses buttons. This can't be done in background, and interfere with users actions, ex. if you touch screen in same time when MacroDroid starts its task..

My conclusion is.. ---> If MicroG would allow its Cloud Messaging to be restarted in background, this would help some developer to make app which would do that in background for us.. And this would resolve problem. But, you cant do that with official MicroG, at least i don't know how.. You must have modified MicroG.

VitalogyRS commented 2 years ago

Seems that with EMUI 12 update it got worse. At least on my P40 lite using latest microg version.

Did you uninstall PowerGenie?

I didn't, no. I'm using a earlier version of MicroG and although it does get disconnected it appears to happen less often (212158). One thing that might make all the sense in the world but I'll mention it anyway: with the do not disturb mode on, the service doesn't disconnect. I just noticed this because at night time I have the do not disturb mode on and when I wake up the service is connected for hours. Don't know if this helps in investigating the problem but here it is.

crotoc commented 2 years ago

Same problem with harmony 2.0 os here. Hope microg can help solve the problem. Missing notification is really bad. My phone is Mate 30 pro and with 0.24214816 microg. I uninstall powergenie and will see what's going on here.

mafs77 commented 2 years ago

P40 lite with new EMUI 12, most of the time it works without issue and for no reason disconects one day. I swap wifi, 4g, with and without VPN several times during the day. Don't know if this can be related to the issue.

mire777 commented 2 years ago

P40 lite with new EMUI 12, most of the time it works without issue and for no reason disconects one day. I swap wifi, 4g, with and without VPN several times during the day. Don't know if this can be related to the issue.

No, this is not the issue..

PowerGenie kills GCM improperly (force close), and after that, even if some app triger GCM again, MicroG doesn't reconnects to GCM. MicroG think its disconnected. Even if you see in settings that button is still set to ON, MicroG thinks it's turned off.

So, MicroG wont reconnect to GCM after being killed (force closed)!

Try this yourself ---> Go in settings/apps, find "MicroG Settings Core", click "Force Stop". Then open MicroG settings app, and you will see that your status turned to "disconnected". This wont be changed untill you manualy click ON/OFF again.

If developer could make MicroG reconnects to GCM after being force closed (killed), there would be no problem, i think. Because, Facebok would example - triger GCM, and MicroG would reconnect itself after that..

I know theres more important issues to read and fix, but again, we need attention here also..

VitalogyRS commented 2 years ago

P40 lite with new EMUI 12, most of the time it works without issue and for no reason disconects one day. I swap wifi, 4g, with and without VPN several times during the day. Don't know if this can be related to the issue.

No, this is not the issue..

PowerGenie kills GCM improperly (force close), and after that, even if some app triger GCM again, MicroG doesn't reconnects to GCM. MicroG think its disconnected. Even if you see in settings that button is still set to ON, MicroG thinks it's turned off.

Does anyone know when MicroG gests reconnected? Because, sometimes when you go and check it says it's been connected for 5 minutes, which means that the service dropped and somehow got reconnected. Although I understand what you mean about Powergenie, I can't quite figure out what triggers it to force close MicroG. For instance, today MicroG was connected for 13h hours straight. Right now it's been connected for 47 minutes. But I didn't manually turn it off and then back on. So, sometimes the service does reconnect, sometimes it doesn't. It's really not easy to understand what's going on.

Thanks

mire777 commented 2 years ago

I can't quite figure out what triggers it to force close MicroG. For instance, today MicroG was connected for 13h hours straight. Right now it's been connected for 47 minutes. But I didn't manually turn it off and then back on. So, sometimes the service does reconnect, sometimes it doesn't. It's really not easy to understand what's going on.

If someting uses battery more than MicroG, then PowerGenie will first kill that app, and after that will kill others. So what you seing is how PowerGenie works, it saves "power". And this cause sometimes MicroG works longer. It is just matter of time when MicroG will be killed.

sometimes when you go and check it says it's been connected for 5 minutes, which means that the service dropped and somehow got reconnected.

This is becuse of network, sometimes network drop, and it reconnects after that. I don't know what time in advanced settings realy mean. I set it to 60sec manualy.. And no matter how you set it up, nothing helps..

crotoc commented 2 years ago

I uninstall powergenie and it seems like I can get notification of ring and eufy without great delay. I also uninstall com.huawei.android.hwaps, not sure what it is. I can not see how much power is consumed by apps from battery option now and it seems like the standby time is shortened very greatly. From 7:30 AM to 21:30, moderate use, the battery has 27% left. And it seems like the line is consistently decreasing without any flat that was observed when powergenie is installed.

Hope developers can help fix this bug: how to restart the service correctly after powergenie kills it. So many Huawei users are painful of not getting notification even with microG installed. I have spent weeks to struggle with installing GSF to get notification and no method is able to work insistently. MicroG is our last hope!

crotoc commented 2 years ago

I tried to reinstall com.huawei.android.hwaps and microG keeps disconnected in less than a couple of hours. But if it's uninstalled, microG can keep connected as long as 8 hours.

crotoc commented 2 years ago

I installed vanced microG as well. It seems like if vanced microG is stopped for a while. Vanced youtube will not connect to the internet and caused microG (not Vanced) to disconnect immediately. So before opening vanced youtube I need to open vanced microG first. I will monitor whether this would disconnect microG.

VitalogyRS commented 2 years ago

For pure luck, I had to made a few changes on my configuration. It took 36h for microG to disconnect and I'm not sure if it wouldn't connect again. I'll test a bit more and get back with what I did

Thank you

crotoc commented 2 years ago

Even only openning Vanced microG, the connection of microG is possibly disrupted. This morning when I checked the microG's connection time, it's around 6 hours. Then I opened vanced microG and vanced youtube then the connection time turned into 3s right after. However, after about two hours I did the same again but it seems like this time microG is keeping connected. It seems like a random thing.

Good news is microG correctly reconnects immediately although vanced microG disrupts its connection. Hope this information help the users of microG and motivate better developments on the software.

For pure luck, I had to made a few changes on my configuration. It took 36h for microG to disconnect and I'm not sure if it wouldn't connect again. I'll test a bit more and get back with what I did

Thank you

I have never seen this long time. Mine is about 10 hours at most. Please share your configuration. Thanks!

VitalogyRS commented 2 years ago

So, let me begin by saying I still get disconnected. And it still is a problem. But it seems it's working better. And let me continue by saying sorry, this post will be a bit long but it gives a bit of context.

My original configuration was GmsCore (version 0.0.24.214816, the latest at the time), GsfProxy (version 0.1.0, the latest at the time) and FakeStore.apk (version 0.1.0, the latest at the time). And I didn't uninstall powergenie. And I was having the same problems with the notifications as everybody else, keep getting disconnected for no reason.

But I was also having problems with an app downloaded from the appGallery it wasn't working. And I sent an email to the developer and to Huawei reporting the situation. And, to my surprise, Huawei's answer was "if you tried to install google services, please factory reset your phone and try again". And they sent me a video proving the app in question did work.

So, I uninstalled all apks from microg, went into recovery mode, deleted the cache partition (not the data partition) and installed the problematic app. And it worked. To be honest, I was very surprised by that but it did work.

So, I installed GmsCore (version 0.0.24.214816, the latest at the time) gave all permissions with exception of the battery optimization, restarted the phone, went back to microg settings to give the battery optimization permission, registered the device, gave permissions to receive push notifications, new restart, locked microG settings (recent apps and swipe down microG settings) and, well, the first time it took, as I mentioned before, around 36h to disconnect. The second time around it took less than that, around 24h. And the problematic app is still working.

So, I guess microG (don't know if a specific apk or configuration) does mess with some apps not allowing them to function properly (that was a surprise) but to get notifications GmsCore is enough. At least for me.

Sorry for the long post but, well, hope it helps someone.

Thank you

mire777 commented 2 years ago

locked microG settings (recent apps and swipe down microG settings) and, well, the first time it took, as I mentioned before, around 36h to disconnect.

This step you mention have some sense. I also tryed that erlier. I locked MicroG app (recent apps > swipe down), and connection last longer. But unfortunately, MicroG would be killed as soon as you get out of Ram. This doesn't help.

Only real solution is that developer modify Microg app..

I tried to do that on my own, to test behaviour. I used accesibility services to keep GCM running in background, i didn't see disconnected status, it seems that this worked, but also i can't display notifications, i broke someting in Microg. Push notifications works only MicroG can't display them. So i gave up, this should do developer.

I don't even know if developer read this?

crotoc commented 2 years ago

locked microG settings (recent apps and swipe down microG settings) and, well, the first time it took, as I mentioned before, around 36h to disconnect.

This step you mention have some sense. I also tryed that erlier. I locked MicroG app (recent apps > swipe down), and connection last longer. But unfortunately, MicroG would be killed as soon as you get out of Ram. This doesn't help.

Only real solution is that developer modify Microg app..

I tried to do that on my own, to test behaviour. I used accesibility services to keep GCM running in background, i didn't see disconnected status, it seems that this worked, but also i can't display notifications, i broke someting in Microg. Push notifications works only MicroG can't display them. So i gave up, this should do developer.

I don't even know if developer read this?

Your guess is after powergenie kills the GCM service, it won't reconnect. Is the issue rooted from microG is killed or only GCM is killed? I want to see the code to see whether I can see which part is in charge of this.

mire777 commented 2 years ago

locked microG settings (recent apps and swipe down microG settings) and, well, the first time it took, as I mentioned before, around 36h to disconnect.

This step you mention have some sense. I also tryed that erlier. I locked MicroG app (recent apps > swipe down), and connection last longer. But unfortunately, MicroG would be killed as soon as you get out of Ram. This doesn't help. Only real solution is that developer modify Microg app.. I tried to do that on my own, to test behaviour. I used accesibility services to keep GCM running in background, i didn't see disconnected status, it seems that this worked, but also i can't display notifications, i broke someting in Microg. Push notifications works only MicroG can't display them. So i gave up, this should do developer. I don't even know if developer read this?

Your guess is after powergenie kills the GCM service, it won't reconnect. Is the issue rooted from microG is killed or only GCM is killed? I want to see the code to see whether I can see which part is in charge of this.

"Com.google.android.gms" is only what was killed, becuse this is only what works in background.

After "com.google.android.gms" was killed (force closed), it wont start again, and theres nothing to start it again. Unless facebook, Instagram or some app that relys on that service start it. But this wont reconnect GCM.

That should be changed, in such way that GCM reconnects every time you start MicroG (com.google.android.gms) again, which would alow instagram, facebook or other apps to triger reconnection and receive messages...

Unfortunately, this would alow GCM to work indefinitely, only for some apps.. Problem is, not all apps triger GCM, some apps was designed to be trigered by GCM, and this is the reason why GCM should work in background..

My solution would be, modified version of "com.google.android.gms" to alow reconnection at every start, and then some app - "service starter" would checking if "com.google.android.gms" is running, if not, then such app would triger it.. Service starter can work in background without any interruption, becuse you can alow that in battery settings..

For code you should search in "res/layout/ask_gcm.xml" - this is i think button which would allow or disable GCM. "@id/permission_allow_button" and "@id/premission_deny_button".

This should be always ON, and then you need some app that would check if "com.google.android.gms" is running, and if not, that app should start it.

Maybe theres other solution such as acessibility services, but i gave up, i didnt test this to the end..

xymeng16 commented 1 year ago

Seems this thread is not active recently, but I think this problem is still not solved.

@mire777 did some wonderful investigations on the reason of disconnect and figure out that some Huawei System App killed microG due to OOM, as said:

This step you mention have some sense. I also tryed that erlier. I locked MicroG app (recent apps > swipe down), and connection last longer. But unfortunately, MicroG would be killed as soon as you get out of Ram. This doesn't help.

But from my side, the situation is different. I am 100% sure that microG is running at the background by checking the logcat. The problem for me here that causes the disconnection is the network issue, see the log:

[07-12 17:06:24.288 25451:4730 D/GmsGcmMcsSvc]
I/O error: javax.net.ssl.SSLException: Read error: ssl=0x70053ddc48: I/O error during system call, Software caused connection abort

[07-12 17:06:24.294 25451:4722 D/GmsGcmMcsSvc]
Teardown initiated, reason: javax.net.ssl.SSLException: Read error: ssl=0x70053ddc48: I/O error during system call, Software caused connection abort

[07-12 17:06:24.295 25451:4722 D/GmsGcmMcsSvc]
Closing all sockets...

[07-12 17:06:24.304 25451:4722 D/GmsGcmMcsSvc]
Scheduling reconnect in 5 seconds...

[07-12 17:09:45.147 25451:4722 D/GmsGcmMcsSvc]
Connect initiated, reason: Intent { act=org.microg.gms.gcm.mcs.RECONNECT flg=0x14 hwFlg=0x900 cmp=com.google.android.gms/org.microg.gms.gcm.TriggerReceiver (has extras) }

[07-12 17:09:45.147 25451:4722 D/GmsGcmMcsSvc]
Connection is not enabled or dead.

[07-12 17:09:45.147 25451:4722 D/GmsGcmMcsSvc]
Closing all sockets...

[07-12 17:09:45.188 25451:4722 D/GmsGcmMcsSvc]
Starting MCS connection...

[07-12 17:09:45.246 25451:4722 D/GmsGcmMcsSvc]
Connected to mtalk.google.com:5228

[07-12 17:09:45.248 25451:4722 D/GmsGcmMcsSvc]
Activated SSL with mtalk.google.com:5228

[07-12 17:09:45.300 25451:11700 D/GmsGcmMcsSvc]
Sending login request...

At 17:06:24.288, the SSL connection is broken, and hence Teardown is initiated. That's normal since we cannot guarantee our network to be 100% stable. And the following logs seem fine (do finalization/closing, schedule reconnection, and schedule other reconnections if network is not available now), until:

[07-12 17:06:24.304 25451:4722 D/GmsGcmMcsSvc]
Scheduling reconnect in 5 seconds...

[07-12 17:09:45.147 25451:4722 D/GmsGcmMcsSvc]
Connect initiated, reason: Intent { act=org.microg.gms.gcm.mcs.RECONNECT flg=0x14 hwFlg=0x900 cmp=com.google.android.gms/org.microg.gms.gcm.TriggerReceiver (has extras) }

At 17:06:24 the reconnection is scheduled in 20 seconds, but the reconnection happens at 17:09:45. Interestingly, the duration is quite larger than 20 seconds. Suddenly I realized that 17:09:45 is very close to when I re-open my screen. And I also realized that disconnection always happens during the screen is off....

Hey hey hey, it looks like when the screen is off, the system will restrict the internet connection (of certain processes) to save energy!

I continue to check the log around the time microG lost the connection, and find something like:

[07-12 17:06:24.415 2760:3728 I/BroadcastAdapter]
Scroff Network status:true pkgs:com.whatsapp    com.huawei.android.pushagent    com.wpengapp.lightstart com.tencent.mm  com.tencent.mobileqq    com.huawei.hwid com.huawei.hidisk   com.android.mms com.mtel.androidbea com.mgoogle.android.gms com.huawei.parentcontrol.parent com.hangseng.rbmobile   com.huawei.localBackup  org.thoughtcrime.securesms  com.huawei.parentcontrol    com.cainiao.cnintl4android  org.telegram.messenger  com.huawei.meetime  com.huawei.smartspeaker com.alibaba.android.rimet   com.huawei.hwvoipservice    hk.alipay.wallet    com.huawei.lbs

[07-12 17:06:24.417 2760:3551 I/DeviceStateService]
now Ctrl Socket, Wlist:[com.whatsapp, com.huawei.android.pushagent, com.wpengapp.lightstart, com.tencent.mm, com.tencent.mobileqq, com.huawei.hwid, com.huawei.hidisk, com.android.mms, com.mtel.androidbea, com.mgoogle.android.gms, com.huawei.parentcontrol.parent, com.hangseng.rbmobile, com.huawei.localBackup, org.thoughtcrime.securesms, com.huawei.parentcontrol, com.cainiao.cnintl4android, org.telegram.messenger, com.huawei.meetime, com.huawei.smartspeaker, com.alibaba.android.rimet, com.huawei.hwvoipservice, hk.alipay.wallet, com.huawei.lbs]

[07-12 17:06:24.417 2760:3728 I/AlarmProxy]
handleCtrlSocketAction : socket state = true, applistStr = com.whatsapp com.huawei.android.pushagent    com.wpengapp.lightstart com.tencent.mm  com.tencent.mobileqq    com.huawei.hwid com.huawei.hidisk   com.android.mms com.mtel.androidbea com.mgoogle.android.gms com.huawei.parentcontrol.parent com.hangseng.rbmobile   com.huawei.localBackup  org.thoughtcrime.securesms  com.huawei.parentcontrol    com.cainiao.cnintl4android  org.telegram.messenger  com.huawei.meetime  com.huawei.smartspeaker com.alibaba.android.rimet   com.huawei.hwvoipservice    hk.alipay.wallet    com.huawei.lbs  

Now I think the problem is clear: When the screen is off for a certain duration, the system will restrict the network connection of lots of apps, excluding those in the above Wlists (whitelist I think). Now we need to find a way to add microG inside it.

I surprisingly aware that com.mgoogle.android.gms (the vanced microG) is included by the whitelist, but I don't know if this is done by Huawei itself or if the whitelist can be modified by users. (Sadly, I prefer the first one...) Anyway, I will try to figure out this problem and comment back here. I just checked the open-sourced mate 40 pro + EMUI 11.0 kernel code and didn't find anything related to above thoughts, maybe checking the source code of com.mgoogle.android.gm/org.telegram.messenger/org.thoughtcrime.securesms should help, if they modify the whitelist in there code.

VitalogyRS commented 1 year ago

Seems this thread is not active recently, but I think this problem is still not solved.

It's still not solved but hopefully you did find the root cause of the problem, thanks for keeping the thread alive and with such useful information

crotoc commented 1 year ago

Thanks for the information. I will check how to add it to whlist as well. How do you check the log?