Setting AVMutableVideoCompositionLayerInstruction transform cause video export failed

I am developing one video edit app. I will add video applying some transform on top of background video for Picture in Picture feature.

I use code below to add transform for top PIP video. But this will cause exporting failed sometimes ,not usually.


CGAffineTransform transform = [stickerInfo generateTransform];
[layerInstruction setTransform:transform atTime:stickerInfo.filterModel.start];

[layerInstruction setOpacity:0.0 atTime:stickerInfo.filterModel.end];
[layerInstructions insertObject:layerInstruction atIndex:0];


The exporting error is Domain=AVFoundationErrorDomain Code=-11819.

After my test, I found the issue code is the second line. If I replace the transform value into

CGAffineTransformIdentity
or other transform, it can be exported successfully. It will also be success if I insert the layerInstruction at end of the array instead of inserting into head. I don't know why.

This bug happened sometimes. Can somebody help? Forgiving my poor english.

The error transform is

(a = 0.30189707177968644, b = -0.00028668135614912858, c = 0.00028668135614912858, d = 0.30189707177968644, tx = 40.548484802246094, ty = 258.6907958984375)
.