Fix a rare issue with gradient draw layer.