Make Paint/Shader/ColorFilter#getNativeInstance conditionally thread-safe
Bug: 159246162 Bug: 154358781 Test: PaintNativeInstanceTest.kt Although the android.graphics package makes no promises regarding thread-safety, it is not obvious to clients how they might call getNativeInstance from multiple threads. If one thread sets up a Paint, and then two threads use it, this sets up a race condition for setting up the native SkPaint. This seems to have been observed in internal apps. Put accesses and modifications to these native objects inside a synchronized block, so that we don't end up with a situation where two instances of mCleaner attempt to dereference the same native object. Add tests in PaintNativeInstanceTest.kt Change-Id: I10fa0958ea216bfbc79667c6217dd6570b3eb110
Loading
Please register or sign in to comment