Hopefully the call to canEncode() won't affect the performance too much... BUG: 263761 (cherry picked from commit 7b75f8a7)