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) {}
}
@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