Repository navigation
[starvation] three more calls that block the UI thread - #2335
Merged
dulmarod merged 1 commit intoNov 27, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.