mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix race condition in Paint.hasGlyph()
The caller of FontFamily::hasVariationSelector needs to acquire the lock before calling it, but FontCollection::hasVariationSelector didn't acquire the lock. This caused a race condition. This CL fixes this race condition. Also, it turned out that assertMinikinLocked didn't assert even on eng or userdebug device. This CL enables assertion on eng and userdebug device since this assertion must be treated as bug. BUG: 26323806 Change-Id: I9c4b1e1f09c6793e387fbdb8bb654cc0a13c65d5
This commit is contained in:
parent
9b120f1134
commit
5f7e7e239e
@ -47,11 +47,18 @@ minikin_shared_libraries := \
|
||||
libicuuc \
|
||||
libutils
|
||||
|
||||
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
|
||||
# Enable race detection on eng and userdebug build.
|
||||
enable_race_detection := -DENABLE_RACE_DETECTION
|
||||
else
|
||||
enable_race_detection :=
|
||||
endif
|
||||
|
||||
LOCAL_MODULE := libminikin
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include
|
||||
LOCAL_SRC_FILES := $(minikin_src_files)
|
||||
LOCAL_C_INCLUDES := $(minikin_c_includes)
|
||||
LOCAL_CPPFLAGS += -Werror -Wall -Wextra
|
||||
LOCAL_CPPFLAGS += -Werror -Wall -Wextra $(enable_race_detection)
|
||||
LOCAL_SHARED_LIBRARIES := $(minikin_shared_libraries)
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
@ -63,7 +70,7 @@ LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include
|
||||
LOCAL_SRC_FILES := $(minikin_src_files)
|
||||
LOCAL_C_INCLUDES := $(minikin_c_includes)
|
||||
LOCAL_CPPFLAGS += -Werror -Wall -Wextra
|
||||
LOCAL_CPPFLAGS += -Werror -Wall -Wextra $(enable_race_detection)
|
||||
LOCAL_SHARED_LIBRARIES := $(minikin_shared_libraries)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
@ -76,7 +83,7 @@ LOCAL_MODULE := libminikin_host
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include
|
||||
LOCAL_C_INCLUDES := $(minikin_c_includes)
|
||||
LOCAL_CPPFLAGS += -Werror -Wall -Wextra
|
||||
LOCAL_CPPFLAGS += -Werror -Wall -Wextra $(enable_race_detection)
|
||||
LOCAL_SHARED_LIBRARIES := liblog libicuuc-host
|
||||
|
||||
LOCAL_SRC_FILES := Hyphenator.cpp
|
||||
|
||||
@ -223,6 +223,7 @@ bool FontCollection::hasVariationSelector(uint32_t baseCodepoint,
|
||||
// Currently mRanges can not be used here since it isn't aware of the variation sequence.
|
||||
// TODO: Use mRanges for narrowing down the search range.
|
||||
for (size_t i = 0; i < mFamilies.size(); i++) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
if (mFamilies[i]->hasVariationSelector(baseCodepoint, variationSelector)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -25,7 +25,9 @@ namespace android {
|
||||
Mutex gMinikinLock;
|
||||
|
||||
void assertMinikinLocked() {
|
||||
LOG_FATAL_IF(gMinikinLock.tryLock() == 0);
|
||||
#ifdef ENABLE_RACE_DETECTION
|
||||
LOG_ALWAYS_FATAL_IF(gMinikinLock.tryLock() == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user