fix redrawing of canvas with an optimized build