                 self.waveformImage = image
                 self.cachedSampleRange = (image != nil) ? renderSampleRange : nil
                 self.renderingInProgress = false
+                self.waveformRenderOperation = nil
                 self.setNeedsLayout()
                 self.delegate?.waveformViewDidRender?(self)
             }
         }
-        self.waveformRenderOperation = waveformRenderOperation
         // TODO: set other values here or require a context to be passed in
         waveformRenderOperation.sampleRange = renderSampleRange
         waveformRenderOperation.imageSize = CGSize(width: widthInPixels, height: heightInPixels)
         waveformRenderOperation.horizontalTargetOverdraw = horizontalTargetOverdraw
         waveformRenderOperation.verticalTargetOverdraw = verticalTargetOverdraw
         waveformRenderOperation.noiseFloor = noiseFloor
+        
+        self.waveformRenderOperation = waveformRenderOperation
+        renderingInProgress = true
+        delegate?.waveformViewWillRender?(self)
+
         waveformRenderOperation.start()
     }
 }


        print("rendering")
        
        renderingInProgress = true
        delegate?.waveformViewWillRender?(self)
        
        let displayRange = zoomEndSamples - zoomStartSamples
        guard displayRange > 0 else { return }


        self.completionBlock = { [weak self] in
            guard let `self` = self else { return }
            self.completionHandler(self.renderedImage)
            self.renderedImage = nil
        }
    }
    
