-
Notifications
You must be signed in to change notification settings - Fork 440
Fix #3113: Fetch adblock data every 6 hours. #3130
Conversation
AdblockResourceDownloader.shared.regionalAdblockResourcesSetup() | ||
AdblockResourceDownloader.shared.generalAdblockResourcesSetup() | ||
let now = Date() | ||
let fetchInterval = AppConstants.buildChannel.isPublic ? 6.hours : 10.minutes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocked to decide on fetch interval, i like to fetch more often than 24hours, set it to 6 for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some randomization to this so it's not as much of a user fingerprint? ex: each time the fetch is supposed to occur, delay it by a random amount between 1 and 10 minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diracdeltas This will only be non-random if the user happens to open their phone every 6 hours since it only triggered on app foreground, not on a specific timer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good :) Nice little debug addition you added for QA.
Not sure if we need a sec review for this since we're adding additional network calls?
let's request a security reivew |
@@ -478,6 +478,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati | |||
if let authInfo = KeychainWrapper.sharedAppContainerKeychain.authenticationInfo(), authInfo.isPasscodeRequiredImmediately { | |||
authenticator?.willEnterForeground() | |||
} | |||
|
|||
AdblockResourceDownloader.shared.startLoading() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a suggestion. what do you think about adding resource downloading into also applicationDidEnterBackground
.
Use background task and use that window efficiently. We can define a background task with
private var backgroundTaskIdentifier: UIBackgroundTaskIdentifier?
backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask {
self.endBackgroundTask()
}
and have an background task finish method like
private func endBackgroundTask() {
guard let backgroundTaskIdentifier = backgroundTaskIdentifier else { return }
UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
self.backgroundTaskIdentifier = nil
}
and also we can have completion block from AdBlockResourceDownloader and end the task If operation is success.
And since we have also resource downloading in foreground this will help us improving the download experience and utilize the background window
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overkill imo, why would you want to download it both when the app goes in background and in foreground?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we will download while going to background using background task, it will not need to download while app is coming foreground and occupy a thread and do processing.
Why we need to add both(background/foreground) is background task can initiate processes that doesnt take too long and there is no guarantee it will succeed so in that case foreground can initialize the process if it is needed.
But yes this is a suggestion, not necessary.
Summary of Changes
This pull request fixes #3113
Security review https://github.com/brave/security/issues/269
Submitter Checklist:
NSLocalizableString()
Test Plan:
adblock debug
last fetch time
valueadblock debug
last fetch
time value changedScreenshots:
Reviewer Checklist:
QA/(Yes|No)
release-notes/(include|exclude)
bug
/enhancement