Revert part of #3108 to avoid rendering garbage memory

Issue #3237