Skip to content

[starvation] three more calls that block the UI thread - #2335

Merged
dulmarod merged 1 commit into
meta:mainfrom
VladimirMakaev:pr/starvation-ui-blocking-1126
Nov 27, 2026
Merged

dulmarod merged 1 commit into
meta:mainfrom
VladimirMakaev:pr/starvation-ui-blocking-1126

Conversation

@VladimirMakaev

Copy link
Copy Markdown
Contributor

Semaphore.acquire, BlockingQueue.take and put, and SystemClock.sleep all block the calling
thread, but none was modelled, so none was reported on the UI thread.

@UiThread
void onCreate() throws InterruptedException {
sem.acquire(); // before: silent
queue.take(); // before: silent
SystemClock.sleep(100); // before: silent
}

The timed forms are named differently - tryAcquire, poll and offer - so they are not matched and
no timeout predicate is needed to let them through, unlike CountDownLatch.await where the bounded
form shares its name.

Limitations: a synchronous AIDL call is recognised through the generated proxy's transact, which
also keeps oneway calls silent; called through the interface type alone it is still missed,
because a oneway method has the same Java signature as a blocking one.

Test plan

java/starvation: BlockingCalls covers the three new models on the UI thread, their timed and
off-thread forms, and the AIDL proxy and oneway cases, with a CountDownLatch.await control.

Semaphore.acquire, BlockingQueue.take and put, and SystemClock.sleep all block the calling
thread, but none was modelled, so none was reported on the UI thread.

  @UiThread
  void onCreate() throws InterruptedException {
    sem.acquire();          // before: silent
    queue.take();           // before: silent
    SystemClock.sleep(100); // before: silent
  }

The timed forms are named differently - tryAcquire, poll and offer - so they are not matched and
no timeout predicate is needed to let them through, unlike CountDownLatch.await where the bounded
form shares its name.

Limitations: a synchronous AIDL call is recognised through the generated proxy's transact, which
also keeps oneway calls silent; called through the interface type alone it is still missed,
because a oneway method has the same Java signature as a blocking one.

## Test plan
java/starvation: BlockingCalls covers the three new models on the UI thread, their timed and
off-thread forms, and the AIDL proxy and oneway cases, with a CountDownLatch.await control.
@meta-cla meta-cla Bot added the CLA Signed label Nov 26, 2026
@dulmarod
dulmarod merged commit 1c6cbab into meta:main Nov 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants