In Lockwise-Android, when the app is used for Autofill, Glean pings are not triggered
Categories
(Data Platform and Tools :: Glean: SDK, task, P4)
Tracking
(Not tracked)
People
(Reporter: travis_, Unassigned)
References
Details
(Whiteboard: [telemetry:glean-rs:backlog])
See the GitHub issue for a full description of the issue and the questions to be resolved. The purpose of this bug is to track the issue from the Glean side of things to ensure it is handled in a timely fashion.
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Comment 1•5 years ago
|
||
After doing some research, I can confirm that when used for Autofill, Lockwise is indeed running as a service, particularly an AutofillService. Since this extends Service
, the service lifecycle events apply and not the activity lifecycle events.
Furthermore, I don't see a way to tie into the service lifecycle events using a method such as the GleanLifecycleObserver
which extends LifecycleEventObserver
. These seem to be geared only towards activity lifecycle events and not service events. It appears that the only way to deal with this on Android will be to do so within the service class, which raises some questions about whether or not Glean has been initialized when the service is running and would require that the implementing service/app would need to likely use a custom ping in order to be able to instrument these service invocations since we don't expose a public API for submitting the baseline ping.
I'm going to do one more test to see if the application is launched and what state Glean is in when the OS invokes Lockwise for Autofill. My suspicion is that Glean may not be initialized in these cases unless the application is already running, but I'm not 100% certain of this due to Android having such fabulous documentation when it comes to some things.
Comment 2•5 years ago
|
||
(In reply to Travis Long [:travis_] from comment #1)
After doing some research, I can confirm that when used for Autofill, Lockwise is indeed running as a service, particularly an AutofillService. Since this extends
Service
, the service lifecycle events apply and not the activity lifecycle events.
Does the service keep on living after it is started? As far as I can see in the code, Lockwise is linking autofill start to "foreground" and autofill end (service closed) to "background". This should trigger at least a 'core' ping when the service is started.
Maybe the Lockwise team can shed some light on the service lifetime? If the service dies after the autofill (unlikely, but still worth checking) then it will send a core ping every time the service is restarted. Which.. well, is a lot of pings :)
Moreover, is the data from the service and the application shared? i.e. if the service sends a 'core' ping, will it have the same 'client_id' of a core ping sent by the application when going to foreground?
Furthermore, I don't see a way to tie into the service lifecycle events using a method such as the
GleanLifecycleObserver
which extendsLifecycleEventObserver
. These seem to be geared only towards activity lifecycle events and not service events. It appears that the only way to deal with this on Android will be to do so within the service class, which raises some questions about whether or not Glean has been initialized when the service is running and would require that the implementing service/app would need to likely use a custom ping in order to be able to instrument these service invocations since we don't expose a public API for submitting the baseline ping.
Let's clarify the intent from the Lockwise team before thinking about the implementation details.
I'm going to do one more test to see if the application is launched and what state Glean is in when the OS invokes Lockwise for Autofill. My suspicion is that Glean may not be initialized in these cases unless the application is already running, but I'm not 100% certain of this due to Android having such fabulous documentation when it comes to some things.
This should not be the case but it's worth double checking.
Reporter | ||
Comment 3•5 years ago
|
||
(In reply to Alessio Placitelli [:Dexter] from comment #2)
(In reply to Travis Long [:travis_] from comment #1)
Does the service keep on living after it is started? As far as I can see in the code, Lockwise is linking autofill start to "foreground" and autofill end (service closed) to "background". This should trigger at least a 'core' ping when the service is started.
As far as I have seen by experimentation, yes. The service is invoked by the OS the instant you focus on a field that supports Autofill, if it's not already running. You can see this in the logcat output as it initializes Glean. If the service is already running, then you see the "don't init Glean more than once" log messages. But, I never see any pings being sent, so either the service stays running or it doesn't see the events.
Where you mention the code that they are "linking autofill end to background", based on the sequence of events that I see in the Lockwise events data, actual background event metrics (which this should trigger), are only recorded if the app is launched and doesn't occur when the service is launched.
Maybe the Lockwise team can shed some light on the service lifetime? If the service dies after the autofill (unlikely, but still worth checking) then it will send a core ping every time the service is restarted. Which.. well, is a lot of pings :)
I already confirmed with @elise on the Lockwise team that lifecycle events for foreground and background may not be seen by the service, although she was going to confirm the exact behavior but hasn't gotten back to me yet.
Moreover, is the data from the service and the application shared? i.e. if the service sends a 'core' ping, will it have the same 'client_id' of a core ping sent by the application when going to foreground?
Yes, the data stores are shared, and it does appear that the service invokes the onCreate
of the application which calls Glean.initialize
. We just don't see the foreground event, that I can see, or the background event, when invoked by the OS for Autofill. I added log outputs for when the lifecycle events are triggered and I don't see them when the app is invoked by the service.
Let's clarify the intent from the Lockwise team before thinking about the implementation details.
Agreed, this bug was only ever about investigation of the issue and determining a way forward, not implementation. I was planning on filing a new bug(s) for that, if needed.
I'm going to do one more test to see if the application is launched and what state Glean is in when the OS invokes Lockwise for Autofill. My suspicion is that Glean may not be initialized in these cases unless the application is already running, but I'm not 100% certain of this due to Android having such fabulous documentation when it comes to some things.
This should not be the case but it's worth double checking.
Already confirmed that you are right, Glean is initialized because the service does invoke the app (but since it never gets "foregrounded" on the UI, we don't see the lifecycle events, which I also confirmed experimentally). You also cannot see it from the task switcher to be able to interact with the app unless it is launched by the user.
Reporter | ||
Comment 4•5 years ago
|
||
It doesn't look like the mobile apps are getting any priority as this issue is now 3 weeks old and still sitting in the Lockwise team's inbox on GitHub. I'm backlogging this and un-taking it. If I see any movement on the GitHub side of things, I'll come back around and update this bug.
Updated•4 years ago
|
Updated•4 years ago
|
Description
•