You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure EnqueuedPixelWorker does not do IO work on main thread (#7110)
Task/Issue URL:
https://app.asana.com/1/137249556945/project/608920331025315/task/1211922784726284?focus=true
### Description
Moves work which can trigger IO to an `io` dispatcher instead of `main`
and `Default` dispatchers that can be used currently.
### Steps to test this PR
Add logcat filter: `unsent clear data pixels|Pixel sent: ml|Pixel sent:
mf`
#### ml pixel
- [x] Launch the app; verify you see `ml` pixel sent
- [x] Switch to another app, then switch back to our app (it's not
always enough just to background it and return). verify you see the `ml`
pixel sent
#### mf pixel
- [x] Apply patch (which triggers the background worker to run
immediately on app launch instead of waiting for it to run after a few
hours); install and launch app
- [x] Use the fire button a few times (_n_ times) to clear data
- [x] Switch to another app, then switch back to ours; verify you see
`Found n unsent clear data pixels` and _n_ instances of `Pixel sent: mf`
### Patch
```
Index: app/src/main/java/com/duckduckgo/app/pixels/EnqueuedPixelWorker.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/src/main/java/com/duckduckgo/app/pixels/EnqueuedPixelWorker.kt b/app/src/main/java/com/duckduckgo/app/pixels/EnqueuedPixelWorker.kt
--- a/app/src/main/java/com/duckduckgo/app/pixels/EnqueuedPixelWorker.kt (revision Staged)
+++ b/app/src/main/java/com/duckduckgo/app/pixels/EnqueuedPixelWorker.kt (date 1762956896767)
@@ -86,6 +86,9 @@
return
}
+ val oneTimeRequest = OneTimeWorkRequestBuilder<RealEnqueuedPixelWorker>().build()
+ workManager.beginUniqueWork("pixel_sender", ExistingWorkPolicy.REPLACE, oneTimeRequest).enqueue()
+
appCoroutineScope.launch(dispatchers.io()) {
sendAppLaunchPixel()
}
```
Co-authored-by: Craig Russell <[email protected]>
0 commit comments