joogps / Glur

A library for progressive blurs in SwiftUI.
https://apps.apple.com/app/glur/id6478063257
MIT License
1.34k stars 21 forks source link

Blur relates from frame modifier. Some values cause entire view to disappear #3

Closed denandreychuk closed 9 months ago

denandreychuk commented 9 months ago

We have gradient view in the project example. If I change only one line of code to make it rect not the square, the view completely disappears:

var gradient: some View {
        LinearGradient(colors: [Color("Color 1"), Color("Color 2"), Color("Color 3")], startPoint: .top, endPoint: .bottom)
            //.aspectRatio(1.0, contentMode: .fit)
            .frame(width: 256, height: 482) <<--- 482 cause view to disappear, while 481 still works fine
            .clipShape(.rect(cornerRadius: 57/2))
            .padding(32)
            .background(Color("Black"))
            .glur(offset: 0.3, interpolation: 0.5, radius: 32.0)
    }
joogps commented 9 months ago

Hey there, @denandreychuk!

This issue is concerning, and seems to be a limitation with how Apple is interfacing SwiftUI with Metal. Apparently, it fails to convert a view into a texture to be used in Metal when either dimension go past 545 points. In the case above, 482 plus 64 points of padding equals 546 which causes a texture conversion error to trigger.

This limit seems to be weirdly low — on Mac, for example, I was able to run the code with no issues. I'll file a radar on it through Feedback Assistant and see how it goes.

joogps commented 9 months ago

I've looked deeper into this and the issue apparently is exclusive to apps running on the iOS simulator. I submitted an issue on feedback assistant (FB13604685) with these specific details — let's see if it gets fixed!

As it's not an urgent issue that directly impacts the quality of the codebase, I'll close this for now and add a disclaimer in the README.

denandreychuk commented 9 months ago

Oh, I see! Thanks for looking into this, @joogps!