The code you posted contains elements after you call saveFrame():
saveFrame()
If this is not representative of the code you’re running, please post a minimal reproducible example that shows your problem. Thanks!