Image Playground Sheet Appears Blank First Time Presented?

I've implemented the imagePlaygroundSheet modifier in my app. It eventually all works but I've consistently noticed that the first time I present it, the sheet is totally blank. I then have to pull down to dismiss it (it doesn't even have a cancel button) and present it a second time and it loads content.

Just me? This is on 18.2 final, iPhone 16 Pro Max.

If you don't provide us any code to have a look at, you're just shouting into the void.

Give us some code we can look at. We may notice what you're doing wrong, but right now we have no idea; you're basically just telling us you have an issue. What do you think we can do with that?!

It was more of a general question about if the API is working correctly for others which of course can be very useful information - pretty common for Apple APIs, especially SwiftUI, to behave in strange ways and sometimes just not work at all.

So that was the purpose - knowing it works fine for everyone else would be useful. That's what the 'just me' question means.

But sure, here's the code. It's basically the same as the sample in the documentation and since this modifier just uses a Bool state for presentation it didn't seem useful.

With the below:

  1. When button pressed, sheet presents as expected.
  2. Sheet is blank, i.e. totally white.
  3. Wait a little bit to see what happens (nothing).
  4. Dismiss sheet with interactive pull dismissal.
  5. Tap button again.
  6. Sheet appears, Image Playgrounds content loads.

Code is as follows in case something does jump out. Maybe you'll see something that I do not.

import SwiftUI

#if canImport(ImagePlayground)
import ImagePlayground
#endif

@available(iOS 18.2, *)
struct TripCustomImageGenerationView: View {
    @Environment(\.supportsImagePlayground) private var supportsImagePlayground
    
    @State private var showImagePlayground: Bool = false
    @State private var data: Data?

    var body: some View {
        if supportsImagePlayground {
            Button("Generate Custom Image") {
                showImagePlayground = true
            }
            .imagePlaygroundSheet(isPresented: $showImagePlayground, concept: "Test Image Concept") { url in
                self.data = try? Data(contentsOf: url)
            }
        } else {
            EmptyView()
        }
    }
}

Hi @Hunter,

I was unable to reproduce this behavior on iOS 18.2, in my tests the Image Playground sheet displays as usual.

If the blank sheet behavior has persisted, can you share a focused sample project that demonstrates the issue so we can take a closer look?

Best,

-J

Thanks, very good to know. I'll see if I can reproduce it in a test project (unfortunately the project it's in is huge) and post here and do a FB.

Image Playground Sheet Appears Blank First Time Presented?
 
 
Q