Make the decoding/rendering loop much more robust.

Fixes lp:1234207

Origin: vendor
Forwarded: no