I was just studying about code of Android framework (v4.1).
I know that the UI message triggered by invalidate()
now is posted to Choreographer instead of UI messageQueue directly, and these messages will not be executed until next VSYNC signal comes.
Before this post operation is performed, ViewRootImpl
calls Looper's postSyncBarrier()
once in order to block the UI MessageQueue which means messages that post into messagesQueue later won't be executed until this block is removed, which happens before function performTraversals()
.
Based on the above understanding,
If another
invalidate()
is called even once somewhere withinperformTraversals()
(such asonDraw()
of any view instances) the UI messageQueue forever be blocked?
From practical observations, I know that this never happens.
So, where am i wrong?
I think you can get the answer to this question by looking at the code for
scheduleTraversals
:After the first call to
scheduleTraversals
mTraversalScheduled
is set true. Subsequent calls have no affect,postSyncBarrier
is not be called and no second barrier is put on the queue, untilunscheduleTraversals
is called.