Hello
I set a few constraints on a UIView in the storyboard. The height constraint is set to 300 and has a size class variation set on 350 (see screenshot).
In my code, I modify the constraint and set its constant to 100. When I call that code, I see the view changing correctly its height to 100. But If I go to homescreen ( app in background) and come back to the app, the height of the view is set back to the old value (300). This problem only appears when the constraint has a size variation. When I remove the variation on the height, the behaviour is ok, the height stays at 100 when I go to homeview and switch back to the app. Is that a bug of AutoLayout ? Is there a workaround ?
(tested with iOS16, on iPhone Xr and iPhone 14 Pro, xcode 14)
class ViewController: UIViewController {
@IBOutlet weak var heightConstraint: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func buttonPushed(_ sender: Any) {
heightConstraint.constant = 100; // works ok until app goes background
}
}
Post not yet marked as solved
In a iOS metal app, I render on a mtkView on a backround thread. I get the current renderDescriptor from the view using mtkView.currentRenderPassDescriptor. I use that renderDescriptor to create a MTLRenderCommandEncoder. That MTLRenderCommandEncoder sometimes have inconsistent size (width, height) during orientation change : _width and _height are different than the size of stored in the currentRenderPassDescriptor. This causes problem when using setScissor method :failed assertion `(rect.x(0) + rect.width(1792))(1792) must be <= render pass width(828)’.So my questions are :why those 2 sizes are different ? Where does the second size come from ?How can I access this second size (MTLRenderCommandEncoder->_width) as it seems the “real size” used to validate the setScissor method?This is a summary of the code :MTLRenderPassDescriptor* renderPassDescriptor = view.currentRenderPassDescriptor;
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(0, 0, 0, 1);
id renderEncoder =
[commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
CGFloat colorAttachementWidth = _passDescriptor.colorAttachments[0].texture.width;
CGFloat colorAttachementHeight = _passDescriptor.colorAttachments[0].texture.height;
MTLScissorRect rect;
rect.x = 0;
rect.y = 0;
rect.width = colorAttachementWidth;
rect.height = colorAttachementHeight;
[renderEncoder setScissorRect:self.scissorRect]; // -> that will trigger the assertionThis is the description of the MTLRenderCommandEncoder when I get the assertion :->
label = MyRenderEncoder
device =
name = Apple A12 GPU
descriptor =
Color Attachment 0
texture =
label = Drawable
textureType = MTLTextureType2D
pixelFormat = MTLPixelFormatBGRA8Unorm
width = 1792 // <——————————————————— this size is not consistent with the size below
height = 828
depth = 1
arrayLength = 1
mipmapLevelCount = 1
sampleCount = 1
cpuCacheMode = MTLCPUCacheModeDefaultCache
storageMode = MTLStorageModeShared
resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared
…
level = 0
slice = 0
depthPlane = 0
resolveTexture =
resolveLevel = 0
resolveSlice = 0
resolveDepthPlane = 0
loadAction = MTLLoadActionClear
storeAction = MTLStoreActionStore
storeActionOptions = none
clearColor = (0 0 0 1)
yInvert = NO
...
Depth Attachment:
texture =
label = Render Depth
textureType = MTLTextureType2D
pixelFormat = MTLPixelFormatDepth32Float
width = 828 // <——————————————————— this size is not consistent
height = 1792
depth = 1
arrayLength = 1
mipmapLevelCount = 1
sampleCount = 1
cpuCacheMode = MTLCPUCacheModeDefaultCache
storageMode = MTLStorageModePrivate
resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModePrivate
usage = MTLTextureUsageRenderTarget
Post not yet marked as solved
HelloI'm implementing an AUV3 extension (AUAudioUnit) and I would like to know how to restore the state of the instance when the extension is loaded from the host. The extension should save/restore several float parameters each time the extension quits/opens. The documentation mentions the "fullState" poperty but it's not clear if/when that propery is set by the host. Also I would like to save a file specific to the running instance. So if 2 instances of the extension are running by the host, there would be two different files saved. Are there several specific directories related to each instance ? Thanks