android-branch-deep-linking-attribution
android-branch-deep-linking-attribution copied to clipboard
Race condition on fetching and using GAID
Describe the bug
It happens to us that a lot of install
requests don't include the field aaid
, but purchase
and new customer
do.
This issue doesn't happen for all the cases.
After investigating, we found that this is potentially a concurrency problem.
On our side, we invoke
Branch.getInstance().disableTracking(..)
This call goes the way down to Branch#registerAppInit()
.
Within this method:
initTasks(request, ignoreWaitLocks);
requestQueue_.processNextQueueItem("registerAppInit");
These 2 calls cause the issue:
-
initTasks
will request to fetch adId asynchronously. -
requestQueue_.processNextQueueItem
create anAsyncTask
(BranchPostTask
) to update GAds Params (throughServerRequest#updateGAdsParams
).
There is a set of locks being introduced that can made the 2nd request requestQueue_.processNextQueueItem
wait for the first one to be finished. However, within initTask
, ignoreWaitLocks
is passed as true
(this value comes from TrackingController#onTrackingEnabled
), as a consequence, lock is not added into the set, so the 2nd request is not aware of the other ones being executed and goes ahead, which leads to the fact that gaid
is potentially not ready when updateGAdsParams
get invoked.
Is this correct or do I miss anything?
Steps to reproduce
- Call
Branch.getInstance().disableTracking(..);
Expected behavior
gaid
is used only after gaid fetching is finished.
SDK Version
5.11
Make and Model
Emulator Pixel 8 API 34
OS
14
Additional Information/Context
No response