Canvas and DOM go out of sync