Closed harishrpatel closed 3 years ago
@harishrpatel could you provide logs showing the event being added. We will either log Analytics - Invalid event:
or Analytics - Adding event:
if its valid. Ill see if I can reproduce locally.
nvm, i see that its being added. Do you see any logs about events uploading ever?
@harishrpatel The only thing I can see that would cause the upload to not happen is if something is cancelling our jobs or scheduling over. Are you using work manager, cancelling work, or cancelling jobs?
@rlepinski I am not doing any of that. We use kotlin coroutines, so not doing anything directly with work manager. Is there any way to flush the event queue by app?
Also on a previous question. When our QA tested, we had production build and we sent 35 events from instant app and full app each. Console saw only 6 of these 70. Unfortunaly we don't have any logs. And I tried about 10 times with debug logging and I never saw a single event on charles. @rlepinski
@harishrpatel Ill have to see what tools are available for debugging the JobManager stuff. Ill get back to you in the AM.
@harishrpatel Right now I am thinking that some other library is either calling [cancelAll](https://developer.android.com/reference/android/app/job/JobScheduler#cancelAll()) on the JobScheduler, or maybe using one of the Airship IDs and scheduling over our Job. Are you able to reproduce this easily? If so, we can rule out the ID conflict by adding this to your manifest under the application entry:
<meta-data android:name="com.urbanairship.job.JOB_ID_START" android:value="11797" />
11797 is just a random number, can be anything. We default to 3000000.
If it's still not working, then I believe something is calling cancelAll()
. In your combined manifest, you should see other SDK job services listed. Example:
<service
android:name="com.urbanairship.job.AndroidJobService"
android:permission="android.permission.BIND_JOB_SERVICE" />
The BIND_JOB_SERVICE
is the permission to look for. Could you provide the dependencies that have this job service? I can take a look at those SDKs to see whats going on. If something else is calling cancelAll()
, that will break our jobs and be very hard to recover from. It's unfortunate that Android exposes that API and not a way to cancel based on a named space.
Finally, you can actually see all scheduled jobs by running adb shell dumpsys jobscheduler | grep <YOUR_PACKAGE_NAME>
. The job ID for uploading events is JOB_ID_START + 0, so 3000000 or whatever you set the JOB_ID_START in your package. Could you provide this output for me. Here is the output for our internal test app (com.urbanairship.goat):
adb shell dumpsys jobscheduler | grep com.urbanairship.goat
<0>com.urbanairship.goat::.schedulePersisted():
<0>com.urbanairship.goat::.schedulePersisted():
JOB #u0a316/3000000: 712cc1e com.urbanairship.goat/com.urbanairship.job.AndroidJobService
u0a316 tag=*job*/com.urbanairship.goat/com.urbanairship.job.AndroidJobService
Source: uid=u0a316 user=0 pkg=com.urbanairship.goat
Service: com.urbanairship.goat/com.urbanairship.job.AndroidJobService
JOB #u0a316/3000004: ceaa0a8 com.urbanairship.goat/com.urbanairship.job.AndroidJobService
u0a316 tag=*job*/com.urbanairship.goat/com.urbanairship.job.AndroidJobService
Source: uid=u0a316 user=0 pkg=com.urbanairship.goat
Service: com.urbanairship.goat/com.urbanairship.job.AndroidJobService
JOB #u0a316/95305998: 6cba31 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService
u0a316 tag=*job*/com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService
Source: uid=u0a316 user=0 pkg=com.urbanairship.goat
Service: com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService
#u0a316/3000004 from u0a316 active: com.urbanairship.goat [RUN_ANY_IN_BACKGROUND allowed] RUNNABLE
#u0a316/3000000 from u0a316 active: com.urbanairship.goat [RUN_ANY_IN_BACKGROUND allowed] RUNNABLE
#u0a316/95305998 from u0a316 active: com.urbanairship.goat [RUN_ANY_IN_BACKGROUND allowed] RUNNABLE
#u0a316/3000004 from u0a316: com.urbanairship.goat RUNNABLE
#u0a316/3000000 from u0a316: com.urbanairship.goat RUNNABLE
#u0a316/95305998 from u0a316: com.urbanairship.goat RUNNABLE
10316: {com.urbanairship.goat}
Timer{<0>com.urbanairship.goat} NOT active, 0 running bg jobs
<0>com.urbanairship.goat
u0a316 / com.urbanairship.goat:
u0a316 / com.urbanairship.goat:
u0a316 / com.urbanairship.goat:
-5s749ms START-P: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService
-4s335ms START: #u0a316/3000005 com.urbanairship.goat/com.urbanairship.job.AndroidJobService
-4s103ms STOP: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService cancelled while waiting for bind
-4s086ms START-P: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService
-3s378ms STOP: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService onStartJob returned false
-3s348ms STOP-P: #u0a316/3000005 com.urbanairship.goat/com.urbanairship.job.AndroidJobService app called jobFinished
While you are doing that, I will see if we can do a better job recovering if something cancels our upload job.
@harishrpatel Right now I am thinking that some other library is either calling [cancelAll](https://developer.android.com/reference/android/app/job/JobScheduler#cancelAll()) on the JobScheduler, or maybe using one of the Airship IDs and scheduling over our Job. Are you able to reproduce this easily? If so, we can rule out the ID conflict by adding this to your manifest under the application entry:
<meta-data android:name="com.urbanairship.job.JOB_ID_START" android:value="11797" />
11797 is just a random number, can be anything. We default to 3000000.
If it's still not working, then I believe something is calling
cancelAll()
. In your combined manifest, you should see other SDK job services listed. Example:<service android:name="com.urbanairship.job.AndroidJobService" android:permission="android.permission.BIND_JOB_SERVICE" />
The
BIND_JOB_SERVICE
is the permission to look for. Could you provide the dependencies that have this job service? I can take a look at those SDKs to see whats going on. If something else is callingcancelAll()
, that will break our jobs and be very hard to recover from. It's unfortunate that Android exposes that API and not a way to cancel based on a named space.Finally, you can actually see all scheduled jobs by running
adb shell dumpsys jobscheduler | grep <YOUR_PACKAGE_NAME>
. The job ID for uploading events is JOB_ID_START + 0, so 3000000 or whatever you set the JOB_ID_START in your package. Could you provide this output for me. Here is the output for our internal test app (com.urbanairship.goat):adb shell dumpsys jobscheduler | grep com.urbanairship.goat <0>com.urbanairship.goat::.schedulePersisted(): <0>com.urbanairship.goat::.schedulePersisted(): JOB #u0a316/3000000: 712cc1e com.urbanairship.goat/com.urbanairship.job.AndroidJobService u0a316 tag=*job*/com.urbanairship.goat/com.urbanairship.job.AndroidJobService Source: uid=u0a316 user=0 pkg=com.urbanairship.goat Service: com.urbanairship.goat/com.urbanairship.job.AndroidJobService JOB #u0a316/3000004: ceaa0a8 com.urbanairship.goat/com.urbanairship.job.AndroidJobService u0a316 tag=*job*/com.urbanairship.goat/com.urbanairship.job.AndroidJobService Source: uid=u0a316 user=0 pkg=com.urbanairship.goat Service: com.urbanairship.goat/com.urbanairship.job.AndroidJobService JOB #u0a316/95305998: 6cba31 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService u0a316 tag=*job*/com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService Source: uid=u0a316 user=0 pkg=com.urbanairship.goat Service: com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService #u0a316/3000004 from u0a316 active: com.urbanairship.goat [RUN_ANY_IN_BACKGROUND allowed] RUNNABLE #u0a316/3000000 from u0a316 active: com.urbanairship.goat [RUN_ANY_IN_BACKGROUND allowed] RUNNABLE #u0a316/95305998 from u0a316 active: com.urbanairship.goat [RUN_ANY_IN_BACKGROUND allowed] RUNNABLE #u0a316/3000004 from u0a316: com.urbanairship.goat RUNNABLE #u0a316/3000000 from u0a316: com.urbanairship.goat RUNNABLE #u0a316/95305998 from u0a316: com.urbanairship.goat RUNNABLE 10316: {com.urbanairship.goat} Timer{<0>com.urbanairship.goat} NOT active, 0 running bg jobs <0>com.urbanairship.goat u0a316 / com.urbanairship.goat: u0a316 / com.urbanairship.goat: u0a316 / com.urbanairship.goat: -5s749ms START-P: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService -4s335ms START: #u0a316/3000005 com.urbanairship.goat/com.urbanairship.job.AndroidJobService -4s103ms STOP: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService cancelled while waiting for bind -4s086ms START-P: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService -3s378ms STOP: #u0a316/95305998 com.urbanairship.goat/com.gimbal.android.jobs.JobManagerService onStartJob returned false -3s348ms STOP-P: #u0a316/3000005 com.urbanairship.goat/com.urbanairship.job.AndroidJobService app called jobFinished
While you are doing that, I will see if we can do a better job recovering if something cancels our upload job.
Thanks so much, let me try that.
@rlepinski I tried all the things you asked above, but no luck. I emailed you output of adb command response.
Thanks.
For anyone with the same problem, this was related to JobService not working for instant apps on Android O+. We moved to work manager in 14.2.0 for better foreground job scheduling and we will now schedule an event upload as soon as the app moves to the background.
Preliminary Info
What Airship dependencies are you using?
What are the versions of any relevant development tools you are using?
Report
What unexpected behavior are you seeing?
Analytics.addEvent() is misfiring. We pushed 70 events and only 6 showed up on Airship Console.
What is the expected behavior?
All events should be POSTED.
What are the steps to reproduce the unexpected behavior?
Just calling the code snippet mentioned above. This had been working perfectly but seems to have broken in last month or so.
Do you have logging for the issue?
Here is what I see on logcat: