Merge pull request #23921 from davidflanagan/bug1064126

Bug 1064126: be more efficient with canvas memory r=russn(cherry picked from commit a5949ec98cf3ed7bb46d8c7b13678ff3c767c71c)
Merge pull request #23965 from davidflanagan/bug1064126-v2.1

Merge pull request #23921 from davidflanagan/bug1064126