Fixes #19652. (cherry picked from commit ffcd6838) (cherry picked from commit 9a24f5ed) (cherry picked from commit ec52cddc)