Monday, March 11, 2024
HomeiOS Developmentios - System orientation dependent SwiftUI Steel drawback: RBLayer: unable to create...

ios – System orientation dependent SwiftUI Steel drawback: RBLayer: unable to create texture: BGRA8Unorm


My iPad app has a View that makes use of a Steel shader as described right here.

#embody <metal_stdlib>
utilizing namespace metallic;

[[ stitchable ]] half4 borderField(float2 place, half4 currentColor, float2 measurement, half4 newColor) {
    assert(measurement.x >= 0 && place.x <= measurement.x);
    assert(measurement.y >= 0 && place.y <= measurement.y);

    // Compute distance to frame
    float dt = measurement.y - place.y;  // Distance to prime
    float db = place.y;     // Distance to backside
    float dl = place.x;      // Distance to left
    float dr = measurement.x - place.x;  // Distance to proper
    float minDistance = min(min(dt, db), min(dl, dr));
    float r = minDistance + 1.0;
    float power = 1.0 / sqrt(r);
    return half4(newColor.rgb, power);

}

It’s utilized to my View utilizing the next modifier:

.colorEffect(ShaderLibrary.fields(.floatArray(viewModel.floatArray)))

The app can use any system orientation.
If I launch it in portrait orientation, the View is displayed accurately:

enter image description here

If I flip the simulator left and launch the app in panorama orientation, the next error is logged:

RBLayer: unable to create texture: BGRA8Unorm, [8.196, 5.200]

and the View will not be coloured:

enter image description here

If I flip the simulator again to portrait mode whereas the app is working, the View is once more coloured accurately.
Nevertheless, if I flip it left once more whereas the app is working, I get as soon as extra the identical error, however the View seems to be now in another way:

enter image description here

I haven’t got expertise in Steel programming, and I do not know what’s mistaken.
There are 2 posts that report the same error, however apparently they don’t apply to my case: This one, and this one.

Any strategies?



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments