Skip to content

Instantly share code, notes, and snippets.

@puls
Last active November 21, 2023 17:16
Show Gist options
  • Select an option

  • Save puls/494dcf4d506f90d3ce1d09c90d1f95aa to your computer and use it in GitHub Desktop.

Select an option

Save puls/494dcf4d506f90d3ce1d09c90d1f95aa to your computer and use it in GitHub Desktop.
Crashing image picker

This is a minimal repro case for a SwiftUI app that exhibits what I think is a system bug.

On my iPhone 12 mini running iOS 14.4 (18D52), the following steps:

  1. Tap the big camera button to bring up the photo library
  2. Focus the search field, notice some jittery layout updates
  3. Scroll the grid of photos

results in the library sheet suddenly disappearing and this message appearing in the console:

2021-01-29 18:19:24.092589-0800 ImagePicker[26722:2433281] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
2021-01-29 18:19:24.092687-0800 ImagePicker[26722:2433467] [lifecycle] [u 7279BB2E-926D-4BC1-A512-78CF64DD6DA6:m (null)] [com.apple.mobileslideshow.photo-picker(1.0)] Connection to plugin interrupted while in use.
2021-01-29 18:19:24.093862-0800 ImagePicker[26722:2433567] [lifecycle] [u 7279BB2E-926D-4BC1-A512-78CF64DD6DA6:m (null)] [com.apple.mobileslideshow.photo-picker(1.0)] Connection to plugin invalidated while in use.
2021-01-29 18:19:24.094082-0800 ImagePicker[26722:2433281] [Generic] -[PUPhotoPickerHostViewController viewServiceDidTerminateWithError:] Error Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
//
// ImagePickerApp.swift
// ImagePickerApp
//
// Created by Jim Puls on 1/29/21.
//
import SwiftUI
// MARK: - ImagePickerApp
@main struct ImagePickerApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
// MARK: - ContentView
struct ContentView: View {
@State var showPicker = false
var body: some View {
Button { showPicker = true } label: {
Image(systemName: "camera.circle.fill")
.resizable()
}
.frame(width: 100, height: 100, alignment: .center)
.sheet(isPresented: $showPicker) {
ImagePicker()
}
}
}
// MARK: - ImagePicker
struct ImagePicker: UIViewControllerRepresentable {
class Coordinator: NSObject {}
func makeCoordinator() -> Coordinator { Coordinator() }
func makeUIViewController(context _: Context) -> UIImagePickerController { UIImagePickerController() }
func updateUIViewController(_: UIImagePickerController, context _: Context) {}
}
@appac
Copy link

appac commented Jun 12, 2021

Curious if you ever found a fix for this? I've run into the exact same issue, same errors and everything and I'm testing on an iPhone 12 Pro Max. I even tried implementing the newer PHPicker/PhotosUI and get the same result.

Testing on an iPhone 7 (with the same iOS version as the iPhone 12), I don't encounter any issues at all, and everything behaves as expected.

I submitted a ticket to Apple in April, since I also assumed it's a bug.

@puls
Copy link
Author

puls commented Jun 14, 2021

I never found a fix for this. Our app still exhibits the bug to this day.

@Chen-Michael
Copy link

+1

Hope it can be solved

@Elvish9090
Copy link

I am also facing same issue. If you have resolved the issue please share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment