Page 1 of 2

Slowdown when tapping notification from lockscreen

Posted: 01 Nov 2016 15:18
by heilong
First-time poster on this forum. Having just bought Automagic, I'm a beginner and just learning it's features. Being a software developer, I decided to jump straight in and tinker with something. I've found a nice collection of flows called SmartUnlock, and already made quite a few of my own modifications to it.

There is a trigger "SmartUnlock_Trigger_Notification" which is triggered by "Notification on Statusbar Selected: All IDs".
1. The phone is locked, screen off.
2. I turn on the screen and double-tap the ongoing SmartUnlock notification.
3. Phone requests my PIN code.
4. I enter the PIN code.
5. PIN code keypad disappears, and for ~2 seconds only lockscreen wallpapers and the Back button on the Navbar are visible.
6. Finally, phone is ready to use.

The ~2 second slowdown only happens if the "SmartUnlock_Trigger_Notification" flow is enabled. Disabling the flow eliminates this slowdown.
If the flow is enabled but empty (e.g. I removed the initial arrow from the trigger), the slowdown still happens.

This only happens when using a secure lockscreen (PIN). Swipe lock doesn't cause this issue.
I'm using Motorola G3 (Osprey) running a CM13-based ROM (Resurrection Remix). This is probably irrelevant, but I'm using CM profile switching for changing the lock screen type, rather than SmartLock's original "Set Pin/Password" way of disabling the lock. I have 3 CM profiles - DefaultLock with the secure (PIN) lockscreen, InsecureLock with "Don't ask for PIN/Password" option - which shows a Swipe lockscreen, and NoLock with "Disable lockscreen" option with no lockscreen/keyguard whatsoever.

P.S. If the "SmartUnlock_Trigger_Notification" flow is disabled, i.e. there is no trigger listening for the notification selection, double-tapping the notification opens Automagic and shows the flow which created that notification. I guess it's a convenient feature for debugging flows (easy to find which flow created a notification), but on the other hand what if I want to create a notification which does nothing when selected? Do I have to add a trigger for that notification anyway, with no actions inside?

P.P.S. For some reason, SmartUnlock's notification trigger listens to all notification IDs, then uses a condition to check if notification_id is equal to global_SmartUnlock_notificationID. If I remove the condition and try to modify the trigger to listen to {global_SmartUnlock_notificationID} only, the flow doesn't get triggered. What's the reason for that?

Re: Slowdown when tapping notification from lockscreen

Posted: 01 Nov 2016 20:50
by Martin
Hi,

I have no idea at what point the slowdown exactly occurs. Did you check the log to see if it's caused by a particular action? Maybe changing the PIN respectively the lock type requires the device to change some encryption keys which could take two seconds depending on CPU or hardware encryption support of the device.

Tapping a notification should always do something on Android, showing the flow was the best fallback since it helps to find the reason of the notification. If you want to create a notification that does nothing, you have to add a trigger to handle the ID.

Most triggers don't support variables in the configuration fields for historical reasons so adding {global_variable} does not get replaced with the actual content of the variable. Fields that support variables will highlight the variable in a blue color.

Regards,
Martin

Re: Slowdown when tapping notification from lockscreen

Posted: 03 Nov 2016 16:32
by heilong
Hey Martin, thanks for your reply.

I'd like to debug this further. SmartUnlock has many flows and writes a lot to the log, it looks like the log's size is limited, so older messages get erased automatically? Just unlocking the screen and going to the log, I can't see the entire log of what happened.
Is there a way to increase the log size? Is there a way to easily export the log to an external file, so I can study it in comfort of my laptop's screen?

Originally SmartUnlock works by changing the PIN, that was a problem for me because changing the PIN freezes the phone for almost 10 seconds (I bet due to hardware encryption, which I'm using). So I've modified SmartUnlock to switch CyanogenMod profiles instead of clearing/setting the PIN. One profile uses the default lockscreen settings, while the other one uses the "don't ask for PIN/password" lockscreen setting. Switching between profiles is instant, since it doesn't actually modify the PIN (CM profiles provide their own Trust Agent, same as Google's Smart Lock, bypassing rather than modifying the lockscreen).

A point to note: just unlocking the locked phone runs SmartUnlock_Trigger_UserPresent which unlocks the device and calls initSmartUnlock. That doesn't cause any slowdown. Double-tapping SmartUnlock runs both that trigger and SmartUnlock_Trigger_Notification. For testing, I've removed all conditions and actions from SmartUnlock_Trigger_Notification, essentially it's empty. Thus the effect of double-tapping the lockscreen notification then entering PIN, or just unlocking and entering PIN, is the same, besides the couple seconds of freezing in the double-tapping the notification case.

I didn't know that tapping the notification should always do something on Android, thanks for explanation. Perhaps this fact would be useful to mention in the Notification trigger help entry? The solution you chose is, indeed, the best fallback I can think of. Creating an empty trigger is an easy workaround, indeed.

Good to know about the blue color highlighting. I really like the highlighting features of Automagic.

Re: Slowdown when tapping notification from lockscreen

Posted: 05 Nov 2016 12:50
by Martin
Hi,

You can enable Log to SD card to preserve a longer log file, maybe also enable Debug Log to get some more detailed log entries.
Automagic stores the file in /storage/emulated/0/Automagic/log.txt (limited to 500kb) and log_old.txt for the previous 500kb. You can also open the log file in menu->Manage->Log, Menu->Open SD Log.

Regards,
Martin

Re: Slowdown when tapping notification from lockscreen

Posted: 05 Nov 2016 13:17
by heilong
Got it. I'll report back when I have some results.
Would it be possible to customize the size limit of the default (in-memory?) log? I would at least double it.

Re: Slowdown when tapping notification from lockscreen

Posted: 05 Nov 2016 13:27
by Martin
I prefer to keep it short to prevent memory issues. The file option actually works quite well for me and it's just two more taps to access it.

Re: Slowdown when tapping notification from lockscreen

Posted: 05 Nov 2016 13:32
by heilong
Got it. Do you keep Log to SD card always selected, or just when debugging some flows? I'm tempted to leave it on all the time, but "might negatively affect performance" makes me wonder if that's a good idea.

Re: Slowdown when tapping notification from lockscreen

Posted: 05 Nov 2016 13:38
by Martin
I keep it on all the time and did not experience any slowdowns lately but this depends on device model and Android version. The old phones (~Android 2.2) with external memory on a real physical SD card had some performance issues when multiple apps wrote to the SD card at the same time but this should not be an issue anymore.

Re: Slowdown when tapping notification from lockscreen

Posted: 05 Nov 2016 13:41
by heilong
Ok cool, I shouldn't have a problem then. Are you also using "Debug log" all the time?

Re: Slowdown when tapping notification from lockscreen

Posted: 05 Nov 2016 13:47
by Martin
Yes, debug log is also turned on all the time on my devices. Debug log has the side effect that the log can be more complex to read so I would not recommend to turn it on in all cases but that's up to you.