Skip to content

Loading…

[Safari/General] Schedule manually updating filter lists less aggressively to give time for garbage collection #978

Closed
chrisaljoudi opened this Issue · 3 comments

2 participants

@chrisaljoudi

Right now, when uBlock is updating filter lists, it grabs and parses them as quickly as it can receive and parse them.

In some cases, when there's a large quantity of those updates, the memory allocation for all the "new" resources occurs before the browser has had a chance to actually garbage collect and deallocate memory.

This is what happens in #964. In the case of Safari, this causes it to run out of memory and crash as it fails trying to allocate more memory. In that case, it took only a couple of large filter lists (EasyList and the Russian list) to reproduce the crash.

This is problematic, especially with cases with a lot of lists/system with little memory. The crash is arguably a Safari bug — it seems like it would be beneficial in general to have filter list updates be less aggressive and more atomic as not to pressure memory.

Perhaps there should be an update task running in the background to perform the updates. It might wait, say, 10 seconds between any two consecutive updates.

In that case, clicking "Update Now" doesn't necessarily go and trigger every request all at once, but rather marks enabled filters as needing an update. The update task, like a janitor, will come along and sweep the needed updates asynchronously.

#965 would make a lot of sense implement alongside this.

@gorhill as always, I'm happy to own this particular fix/issue if you don't have time to work on it. Please let me know.

@chrisaljoudi chrisaljoudi changed the title from [Safari/General] Make updating filter lists less aggressive to give time for garbage collection to [Safari/General] Schedule updating filter lists less aggressively to give time for garbage collection
@gorhill gorhill added the fixing label
@gorhill

When you say "give time for garbage collection", how many seconds to do you in mind?

@chrisaljoudi

@gorhill 3-5 seconds seems to be plenty. Minimum one could get away with is around 1s.

@gorhill gorhill added a commit that referenced this issue
@gorhill gorhill this fixes #982, #978, #965 39ad158
@gorhill gorhill added a commit that referenced this issue
@gorhill gorhill this fixes #990 + code review for #978 145e5da
@gorhill

Fixed in 39ad158.

@gorhill gorhill closed this
@gorhill gorhill removed the fixing label
@gorhill gorhill changed the title from [Safari/General] Schedule updating filter lists less aggressively to give time for garbage collection to [Safari/General] Schedule manually updating filter lists less aggressively to give time for garbage collection
@ahmadassaf ahmadassaf pushed a commit to ahmadassaf/uBlock that referenced this issue
@gorhill gorhill this fixes #978 2e8adfe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.