Skip to content
Commit eb039c3f authored by Avichal Rakesh's avatar Avichal Rakesh
Browse files

ImageWriter: remove mCloseLock guard from queue and dequeue operations

mCloseLock currently guards #queueInputImage, #dequeueInputImage, and
#postEventFromNative. However, there have been cases reported where a
contention between #postEventFromNative and #queueInputImage would lead
to a deadlock. This CL removes the mCloseLock guard from #queueInputImage
and #dequeInputImage as the native implementations are already
synchronized on `this` and there are no reported bugs from race
conditions in those two functions.

It also drops the mCloseLock guard from #postEventFromNative and moves
the responsibility of ensuring ImageWriter is valid to the
ListenerHandler. This ensures that mCloseLock is never in contention
in the JNI thread that calls #postEventFromNative.

#close() is still protected by mCloseLock to prevent multiple
simultaneous closes.

Bug: 263395157
Test: Existing ImageWriter tests pass
      Ran the sequence that led to deadlock 30 times without a single
      deadlock.
Change-Id: I5b0d367cce7df9401386e5a53c5e9b539d8c1f40
parent da209b10
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment