Backport #31130 by @lunny Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> (cherry picked from commit e6bacf1fed57e33fcbbb7d57782bfc5daa8f2fee)