The temporary buffer used in the current implementation of replaceTextureRegion method in MTLBlitLoops.m has an incorrect size. This size is always larger than needed - hence we do not see crashes.
Here is the illustration -
For exaple, if the source RGBA image is of size 1000 x 1000, out of this, if we need to use 10 x 10 (dw x dh) region to be copied to the destination.
Current temp buffer size is :
= Source ScanStride * dh
= Souce width * pixelStride * dh
= 1000 * 4 * 10
= 40000 bytes
What temp buffer size needed is :
= dw * dh * pixelStride
= 10 * 10 * 4
= 400 bytes
Here is the illustration -
For exaple, if the source RGBA image is of size 1000 x 1000, out of this, if we need to use 10 x 10 (dw x dh) region to be copied to the destination.
Current temp buffer size is :
= Source ScanStride * dh
= Souce width * pixelStride * dh
= 1000 * 4 * 10
= 40000 bytes
What temp buffer size needed is :
= dw * dh * pixelStride
= 10 * 10 * 4
= 400 bytes