Fix the flickering problem
Merge pull request #8376 from certik/issue3971

Fix the flickering problem