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 #23966 from davidflanagan/bug1064126-v2.0

Merge pull request #23921 from davidflanagan/bug1064126