mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-07-21 02:05:52 +00:00
Fix GIF emotion switching crash: hide emoji_image_ before destroying gif_controller_
The crash was caused by a race condition in SetEmotion() where two separate DisplayLockGuard scopes allowed the LVGL render task to access freed GIF image data between lock scopes. By hiding emoji_image_ before destroying gif_controller_ in the same lock scope, LVGL won't try to render the image with freed data during the gap. Co-authored-by: 78 <4488133+78@users.noreply.github.com>
This commit is contained in:
co-authored by
78
parent
01603c5112
commit
a6357c4640
@@ -1079,6 +1079,11 @@ void LcdDisplay::SetEmotion(const char* emotion) {
|
||||
if (gif_controller_) {
|
||||
DisplayLockGuard lock(this);
|
||||
gif_controller_->Stop();
|
||||
// Hide image before destroying GIF controller to prevent LVGL from
|
||||
// accessing freed image data during rendering between lock scopes
|
||||
if (emoji_image_) {
|
||||
lv_obj_add_flag(emoji_image_, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
gif_controller_.reset();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user