Fix race condition in GIF emotion switching causing crash (#1848)
* Initial plan * 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> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: 78 <4488133+78@users.noreply.github.com>
This commit is contained in:
@ -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