Opened 3 years ago

Closed 3 years ago

#4794 closed defect (fixed)

adblock engine creating/releasing concurrency

Reported by: asmirnov Assignee: asmirnov
Priority: P2 Milestone:
Module: Libadblockplus-Android Keywords:
Cc: diegocarloslima, fhd Blocked By:
Blocking: Platform: Android
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29371750/

Description

Environment

Adblock engine can be created asynchronously in order not to block main UI: retain(true):
https://hg.adblockplus.org/libadblockplus-android/file/tip/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java#l189

Later we need to make sure creating is finished before getting instance reference: waitForReady():
https://hg.adblockplus.org/libadblockplus-android/file/tip/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java#l141

In the very rare cases the thread can created but not started (https://hg.adblockplus.org/libadblockplus-android/file/tip/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java#l199) when checking for ready as engineCreated instance is still null. So in waitForReady() we will get exception:
https://hg.adblockplus.org/libadblockplus-android/file/tip/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java#l145

How to reproduce

  1. Create adblock engine async with retain(true)
  2. Invoke waitForReady() immediately

Observed behaviour

Getting runtime exception

Expected behaviour

it should wait for the thread to start and block until the instance is created

Change History (5)

comment:1 Changed 3 years ago by asmirnov

comment:2 Changed 3 years ago by asmirnov

  • Summary changed from adblock engine creating concurrency to adblock engine creating/releasing concurrency

comment:3 Changed 3 years ago by asmirnov

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:4 Changed 3 years ago by abpbot

A commit referencing this issue has landed:
Issue 4794 - adblock engine creating/releasing concurrency

comment:5 Changed 3 years ago by asmirnov

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.