Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics

Post

Replies

Boosts

Views

Activity

WKWebView IOSurface leak?
While investigating an apparent IOSurface leak in my app, which makes heavy use of WKWebViews, I found that if I simply create an empty web view and start changing page zoom by pinching, I can see the number of IOSurfaces steadily increasing. Programmatically changing the zoom also has this effect. The controller below gets to 3.58GB of persistent IOSurface objects in about 20 seconds. This behavior continues indefinitely. Is this a leak? I don't think this is just related to zooming, tapping and scrolling also seem to leak IOSurfaces. The problem I was investigating occurs without any of this, just dynamically modifying a web page containing svgs, but I wonder if this is somehow related, as the allocation stack traces are all the same. I'm running on iOS 18.1.1 on an iPad Pro 12.9in 4th gen. class LeakTestController: UIViewController { private(set) var webView: WKWebView! init() { super.init(nibName: nil, bundle: nil) } required init?(coder: NSCoder) { nil } override func viewDidLoad() { let config = WKWebViewConfiguration() webView = WKWebView(frame: .zero, configuration: config) view.addSubview(webView) webView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ view.topAnchor.constraint(equalTo: webView.topAnchor), view.bottomAnchor.constraint(equalTo: webView.bottomAnchor), view.leadingAnchor.constraint(equalTo: webView.leadingAnchor), view.trailingAnchor.constraint(equalTo: webView.trailingAnchor) ]) webView.loadHTMLString("hi", baseURL: nil) startZooming() } func startZooming() { Task.init { while true { try await Task.sleep(nanoseconds: 1000000) webView.pageZoom = 0.5 try await Task.sleep(nanoseconds: 1000000) webView.pageZoom = 1 } } } } The stack trace for the allocations is: IOSurfaceClientLookupFromMachPort -[IOSurface initWithMachPort:] WebCore::IOSurface::createFromSendRight(WTF::MachSendRight const&&) decltype(auto) std::__1::__variant_detail::__visitation::__base::__dispatcher<1ul>::__dispatch[abi:sn180100]<std::__1::__variant_detail::__visitation::__variant::__value_visitor<WTF::Visitor<WebKit::RemoteLayerBackingStoreProperties::layerContentsBufferFromBackendHandle(std::__1::variant<WebCore::ShareableBitmapHandle, WTF::MachSendRight>&&, WebKit::LayerContentsType)::$_0, WebKit::RemoteLayerBackingStoreProperties::layerContentsBufferFromBackendHandle(std::__1::variant<WebCore::ShareableBitmapHandle, WTF::MachSendRight>&&, WebKit::LayerContentsType)::$_1>>&&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, WebCore::ShareableBitmapHandle, WTF::MachSendRight>&>(std::__1::__variant_detail::__visitation::__variant::__value_visitor<WTF::Visitor<WebKit::RemoteLayerBackingStoreProperties::layerContentsBufferFromBackendHandle(std::__1::variant<WebCore::ShareableBitmapHandle, WTF::MachSendRight>&&, WebKit::LayerContentsType)::$_0, WebKit::RemoteLayerBackingStoreProperties::layerContentsBufferFromBackendHandle(std::__1::variant<WebCore::ShareableBitmapHandle, WTF::MachSendRight>&&, WebKit::LayerContentsType)::$_1>>&&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, WebCore::ShareableBitmapHandle, WTF::MachSendRight>&) WebKit::RemoteLayerBackingStoreProperties::layerContentsBufferFromBackendHandle(std::__1::variant<WebCore::ShareableBitmapHandle, WTF::MachSendRight>&&, WebKit::LayerContentsType) WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer*, WebKit::RemoteLayerTreeNode*, WebKit::RemoteLayerTreeHost*, WebKit::LayerProperties const&, WebKit::LayerContentsType) WebKit::RemoteLayerTreePropertyApplier::applyProperties(WebKit::RemoteLayerTreeNode&, WebKit::RemoteLayerTreeHost*, WebKit::LayerProperties const&, WTF::HashMap<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::PlatformLayerIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits<unsigned long long>, unsigned long long>>, std::__1::unique_ptr<WebKit::RemoteLayerTreeNode, std::__1::default_delete<WebKit::RemoteLayerTreeNode>>, WTF::DefaultHash<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::PlatformLayerIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits<unsigned long long>, unsigned long long>>>, WTF::HashTraits<WebCore::ProcessQualified<WTF::ObjectIdentifierGeneric<WebCore::PlatformLayerIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits<unsigned long long>, unsigned long long>>>, WTF::HashTraits<std::__1::unique_ptr<WebKit::RemoteLayerTreeNode, std::__1::default_delete<WebKit::RemoteLayerTreeNode>>>, WTF::HashTableTraits> const&, WebKit::LayerContentsType) WebKit::RemoteLayerTreeHost::updateLayerTree(IPC::Connection const&, WebKit::RemoteLayerTreeTransaction const&, float) WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree(IPC::Connection&, WTF::Vector<std::__1::pair<WebKit::RemoteLayerTreeTransaction, WebKit::RemoteScrollingCoordinatorTransaction>, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&, WTF::HashMap<WTF::ObjectIdentifierGeneric<WebKit::RemoteImageBufferSetIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits<unsigned long long>, unsigned long long>, std::__1::unique_ptr<WebKit::BufferSetBackendHandle, std::__1::default_delete<WebKit::BufferSetBackendHandle>>, WTF::DefaultHash<WTF::ObjectIdentifierGeneric<WebKit::RemoteImageBufferSetIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits<unsigned long long>, unsigned long long>>, WTF::HashTraits<WTF::ObjectIdentifierGeneric<WebKit::RemoteImageBufferSetIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits<unsigned long long>, unsigned long long>>, WTF::HashTraits<std::__1::unique_ptr<WebKit::BufferSetBackendHandle, std::__1::default_delete<WebKit::BufferSetBackendHandle>>>, WTF::HashTableTraits>&&) WebKit::RemoteLayerTreeDrawingAreaProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) IPC::Connection::dispatchMessage(WTF::UniqueRef<IPC::Decoder>) IPC::Connection::dispatchIncomingMessages() WTF::RunLoop::performWork() WTF::RunLoop::performWork(void*) __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ __CFRunLoopDoSource0 __CFRunLoopDoSources0 __CFRunLoopRun CFRunLoopRunSpecific GSEventRunModal -[UIApplication _run] UIApplicationMain 0x192173f40 static UIApplicationDelegate.main() static AppDelegate.$main() __debug_main_executable_dylib_entry_point start
3
0
206
1w
must use voip + livekit to developing, When incoming offline messages arrive at the device through VoIP, call ConversationManager The method of reporting NewIncomingConversation (uuid: update:) will crash in second or more time
now i must use voip + livekit to developing, When incoming offline messages arrive at the device through VoIP, call ConversationManager The method of reporting NewIncomingConversation (uuid: update:) only first time can push new system UI,second or more time will crash, and acrsh stack appears to indicate that callkit has not been called
0
0
136
1w
Issue with Long Press and Drag Gesture Not Ending When Another Finger Swipes on watchOS
I am developing a watchOS app with a tab view, and inside one of the tabs, I have a 2x2 collection view layout. Each collection item contains a view that handles: Tap Gesture (.onTapGesture) → Executes an action immediately. Long Press Gesture (LongPressGesture) → Triggers an update when long press starts and again when it ends. Drag Gesture (DragGesture) → Updates the position while dragging and resets values when the gesture ends. Issue: Most of the time, the gestures work correctly, but if another finger swipes on the screen while a long press is active, sometimes the onEnded event does not trigger, leaving the button in an active state. Observations: The onTapGesture executes normally without issues. The LongPressGesture starts as expected, but if another finger interacts with the screen, the onEnded of the drag gesture does not always trigger. This results in the button remaining visually or functionally "pressed" until another interaction occurs. Has anyone encountered similar behavior in watchOS? How can I ensure that long press and drag gestures always complete even when another finger swipes on the screen? Thanks in advance!
1
0
193
1w
Core Data Migration: Custom policy in Entity Mapping for the case where App name contains a space
I am trying to add a custom policy to Entity Mapping and it refuses to work because the app name has a space in it. I tried replacing the space character with underscore and hyphen but it still does not work. I tried creating an MVP where app name did not have any space and it worked in the first try. However, for another MVP where app name had a space in it, it is not working at all.
4
0
298
1w
LinearGradient not completely filling shape
I am working through an Apple Developer SwiftUI Landmarks Tutorial using Xcode 16.2 on a M2 Pro Mac mini with OSX 14.7 (Sonoma). Under Drawing paths and Shapes, the step where they draw the background, the linearGradient is not filling the top and bottom of the hex shape. If I use a solid fill the shape is filled. I've attached a screenshot from the tutorial showing the entire shape filled with the linear gradient, a screen shot from Xcode showing the gradient not filling the top and bottom of the shape and a screen shot from Xcode showing that a solid fill does work. I found one online mention that implies that this started when the author upgraded to Xcode 16. Since the tutorial was written for Xcode 15, I assume that it worked there.
4
0
178
1w
Is it possible to get selected text from a Text field?
Basically the title. If a Text field has textSelection enabled, is there anyway to get the text that the user has highlighted? Text("My text here") .textSelection(.enabled) Ultimately, my goal is to be able to highlight text and apply style to individual characters. Using a TextField would give my app the ability to know what's been highlighted, but then I can't style individual elements. I'd like to be able to do this in SwiftUI without having to drop into TextKit. struct MyTextEditorView: View { @State var myText: String = "" @State var textSelection: TextSelection? = nil var body: some View { TextField("Placehodler", text: $myText, selection: $textSelection) } }
3
0
257
1w
TextField .alignmentGuide in Form leading point varies?
I have a Form with a custom TextField which uses a custom Text(). When I use .alignmentGuide on the Text() it seems the origin reference point varies with the length of, but not by the length of, the TextField label String. This is a problem when in a Form. My workaround has been to not use a TextField label but enclose the each TextField in a LabeledContent and then I can set the width of the label and align off of that. How does Form cause TextField to set it's width and why if using .alignmentGuide on Text() does the TextField label length even matter?
1
0
121
1w
Set UILabel color in alertController
I have an alertController that is presented as popover on iPad let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: alertStyle) if let ppc = alertController.popoverPresentationController { // … } Is it possible to change the message font color (which is really very light on iPad) ? It is OK on iPhone with the same alert (not popover): text is much more readable:
1
0
134
1w
Apple Maps annotations and markers
In Apple's Maps app, an annotation is made up of a circle shape or rounded rectangles with a glyph-image. When selecting an annotation, the annotation animates into a balloon marker (see attached GIF). How does Apple Maps solve this - from custom annotation to balloon marker with spring animation? I switched my Maps implementation from SwiftUI to UIKit with a UIViewRepresentable to support annotation clustering - and it works beautifully. But how to subclass an MKAnnotationView (or MKMarkerAnnotationView <- the balloon) to enable selection and animation as in Apple Maps? MKMarkerAnnotationView only show balloon markers and I tried everything inside MKAnnotationView (CALayer, etc.)
1
0
141
1w
Inconsistency Between Translation API Language Identifiers and Foundation Locale
I recently noticed an inconsistency in how languages are represented in Apple’s new Translation API compared to Foundation’s Locale system. Observation from the Translation API When retrieving the list of supported languages using: let availableLanguages = try await LanguageAvailability().supportedLanguages The results are: Language(components: Foundation.Locale.Language.Components(languageCode: Optional(uk), script: nil, region: Optional(UA))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(zh), script: nil, region: Optional(TW))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(ko), script: nil, region: Optional(KR))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(en), script: nil, region: Optional(GB))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(de), script: nil, region: Optional(DE))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(zh), script: nil, region: Optional(CN))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(ja), script: nil, region: Optional(JP))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(id), script: nil, region: Optional(ID))) Language(components: Foundation.Locale.Language.Components(languageCode: Optional(nl), script: nil, region: Optional(NL))) .... Key points: • The script component is always nil. • Region codes (CN, TW, etc.) determine the script for languages like Chinese (Simplified or Traditional). • Other languages (e.g., en-GB, en-US, pt-BR) also rely on region-based identification. Observation from Foundation Locale (Locale.current.language) When retrieving the user’s system language setting: systemLanguageObj = Locale.current.language I get a different format where the script component is present, but the region may vary based on user settings. This means that mapping between script and region is not consistent between the two APIs, requiring manual handling. My key questions: 1. Is my current approach correct, or is there a better way to get user language settings that match Translation API identifiers? 2. If no alternative exists, could the Translation API align its language identification method with Foundation Locale to reduce ambiguity? Any insights or suggestions would be greatly appreciated!
1
0
114
1w
Reduce padding, spacing between list section header and search bar
Anyone know how to reduce the padding between list section header (plain style) and search bar? I have tried all available method on google but none work. The default list style does not have this big padding/space between the section header and the search bar. struct Demo: View { @State private var searchText: String = "" var body: some View { NavigationStack { List { Section { ForEach(0..<100) { index in Text("Sample value for \(index)") } } header: { Text("Header") .font(.headline) } } .listStyle(.plain) .navigationTitle("Demo") .navigationBarTitleDisplayMode(.inline) .searchable(text: $searchText) } } }
0
0
74
1w
`.refreshable(action:)` `s indicator will not dismiss after when app into backgound (iOS 17.1)
Hello, I am encountering an issue with .refreshable(action:) in ScrollView. The refresh action works as expected when performing a pull-to-refresh. However, if I put the app in the background while the refresh operation is in progress, the refresh indicator remains visible on the screen when I return to the foreground and does not disappear. Once I interact with the ScrollView after returning to the foreground, the refresh indicator disappears, and the functionality itself is not affected. I initially attempted to resolve this issue by triggering a view redraw when scenePhase changes. However, since my app presents the SwiftUI view using UIHostingController, the scenePhase from the environment does not seem to function correctly. This issue occurs on iOS 17.1 but does not appear on iOS 16.1.1. Is there a known way to resolve this unexpected behavior? Below is a simplified sample code (some parts are omitted): struct MyView: View { @StateObject private var model: MyModel var body: some View { ScrollView { // My ContentViews... } .refreshable { do { try await self.model.refresh() } catch { // Handle error } } } } @MainActor final class MyModel: ObservableObject { // === Some Code === func refresh() async throws { let data = try await self.fetchData() self.data = Array(OrderedSet(data)) } } I apologize for any mistakes in my English, as I am using a translation tool. Thank you in advance for your help! Best regards,
0
0
106
1w
Detect user's tap on status bar
I have an app which uses Scene var body: some Scene { WindowGroup { RootView(root: appDelegate.root) .edgesIgnoringSafeArea(.all) .onOpenURL { url in let stringUrl = url.absoluteString if (stringUrl.starts(with: "http")) { handleUniversalLink(url: stringUrl) } else if (stringUrl.starts(with: "fb")) { let _ = ApplicationDelegate.shared.application( UIApplication.shared, open: url, sourceApplication: nil, annotation: [UIApplication.OpenURLOptionsKey.annotation]) } } } } I need to detect when a user taps on status bar. And call some functions when he does it. Is it possible in Swift?
0
0
112
2w
.sheet or .fullScreenSheet Looping when presenting Image Picker on visionOS
I am having issues with my app on visionOS. It works fine on iOS. The app is presenting a ImagePicker, I had tried converting to PhotoPicker and the behavior did not change. The relevant code is in the EditGreetingCardView - // // Created by Michael Rowe on 1/2/24. // import AVKit import SwiftData import SwiftUI struct EditGreetingCardView: View { @Environment(\.modelContext) private var modelContext @Environment(\.dismiss) private var dismiss @Query(sort: \EventType.eventName) private var events: [EventType] var greetingCard: GreetingCard? private var editorTitle: String { greetingCard == nil ? "Add Greeting Card" : "Edit Greeting Card" } @State var frontImageSelected: Image? = Image("frontImage") @State var sourceType: UIImagePickerController.SourceType = .photoLibrary @State var frontPhoto = false @State var captureFrontImage = false var eventTypePassed: EventType? @State private var eventType: EventType? @State private var cardName = "" @State private var cardManufacturer = "" @State private var cardURL = "" @State private var cardUIImage: UIImage? @State private var cameraNotAuthorized = false @State private var isCameraPresented = false @State private var newEvent = false @AppStorage("walkthrough") var walkthrough = 1 init(eventTypePassed: EventType?) { if let eventTypePassed { _eventType = .init(initialValue: eventTypePassed) } } init(greetingCard: GreetingCard?) { self.greetingCard = greetingCard _eventType = .init(initialValue: greetingCard?.eventType) } var body: some View { NavigationStack { Form { Section("Occasion") { Picker("Select Occasion", selection: $eventType) { Text("Unknown Occasion") .tag(Optional<EventType>.none) //basically added empty tag and it solve the case if events.isEmpty == false { Divider() ForEach(events) { event in Text(event.eventName) .tag(Optional(event)) } } } } .foregroundColor(Color("AccentColor")) Section("Card details") { } .foregroundColor(Color("AccentColor")) Section("Card Image") { HStack(alignment: .center){ Spacer() ZStack { Image(uiImage: cardUIImage ?? UIImage(named: "frontImage")!) .resizable() .aspectRatio(contentMode: .fit) .shadow(radius: 10 ) Image(systemName: "camera.fill") .foregroundColor(.white) .font(.largeTitle) .shadow(radius: 10) .frame(width: 200) .onTapGesture { self.frontPhoto = true } .actionSheet(isPresented: $frontPhoto) { () -> ActionSheet in #if !os(visionOS) ActionSheet( title: Text("Choose mode"), message: Text("Select one."), buttons: [ ActionSheet.Button.default(Text("Camera"), action: { checkCameraAuthorization() self.captureFrontImage.toggle() self.sourceType = .camera }), ActionSheet.Button.default(Text("Photo Library"), action: { self.captureFrontImage.toggle() self.sourceType = .photoLibrary }), ActionSheet.Button.cancel() ] ) #else ActionSheet( title: Text("Choose mode"), message: Text("Select one."), buttons: [ ActionSheet.Button.default(Text("Photo Library"), action: { self.captureFrontImage.toggle() self.sourceType = .photoLibrary }), ActionSheet.Button.cancel() ] ) #endif } .fullScreenCover(isPresented: $captureFrontImage) { #if !os(visionOS) ImagePicker( sourceType: sourceType, image: $frontImageSelected) .interactiveDismissDisabled(true) #else ImagePicker( image: $frontImageSelected) .interactiveDismissDisabled(true) #endif } } .frame(width: 250, height: 250) Spacer() } } } .alert(isPresented: $cameraNotAuthorized) { Alert( title: Text("Unable to access the Camera"), message: Text("To enable access, go to Settings > Privacy > Camera and turn on Camera access for this app."), primaryButton: .default(Text("Settings")) { openSettings() } , secondaryButton: .cancel() ) } .toolbar { } .onAppear { } .onChange(of: frontImageSelected) { oldValue, newValue in cardUIImage = newValue?.asUIImage() } } } }
2
0
149
2w
How to initialize @Observable object in View via @State?
When I switched to observable, I noticed a strange behavior of the ViewModel. The ViewModel is created 3x times. And my question is: How to properly initialize the ViewModel via state? Below is a minimal example with log output: ViewModel INIT : EBBB2C41 ViewModel INIT : D8E490DA ViewModel INIT : 54407300 ViewModel DEINIT: D8E490DA @Observable final class ViewModel { @ObservationIgnored let idd: UUID init() { idd = UUID() print("ViewModel INIT : \(idd.uuidString.prefix(8))") } deinit { print("ViewModel DEINIT: \(idd.uuidString.prefix(8))") } } struct SimpleView: View { @Environment(ViewModel.self) private var viewModel var body: some View { @Bindable var viewModel = viewModel Text("SimpleView: \(viewModel.idd.uuidString.prefix(8))") } } struct ContentView: View { @State private var viewModel = ViewModel() var body: some View { SimpleView() .environment(mainViewModel) } }
1
0
162
2w
QuickLook Library updated text tampered on PDF
We were using below delegate methods from QuickLook to get modified PDF file URL after the sketching But we are not able see the multi line text properly laid out on PDF and part of text missing. Same time Other pencil kit tools are working as expected. `func previewController(_ controller: QLPreviewController, didSaveEditedCopyOf previewItem: QLPreviewItem, at modifiedContentsURL: URL) func previewController(_ controller: QLPreviewController, didUpdateContentsOf previewItem: any QLPreviewItem)` We tested all code in iOS 18.2. Please let us know if the text edited URL on PDF can be retrieved in any possible way without tampering text
0
0
124
2w
[Bug] UIDocumentPickerViewController Crash: “DocumentManager service tried to send a message to a deallocated host proxy”
We are experiencing an issue where UIDocumentPickerViewController causes an uncaught exception when it is dismissed under certain conditions. The error appears as: <NSXPCConnection: 0x301ac7660> connection from pid 2075 on anonymousListener or serviceListener: Warning: Exception caught during invocation of selector _updateRemoteBarButtonFrames:forUUID:, dropping incoming message and invalidating the connection. Exception: DocumentManager service tried to send a message to a deallocated host proxy DocumentManager service tried to send a message to a deallocated host proxy ( 0 CoreFoundation 0x0000000186c2a608 0013A8B1-2524-3534-B5BA-681AAF18C798 + 185864 1 libobjc.A.dylib 0x00000001841a5244 objc_exception_throw + 88 2 Foundation 0x000000018602eec0 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 8576704 3 DocumentManager 0x00000002177cf7b8 0BAEFA1B-BD6D-3472-A1B3-6E09F5DE54F2 + 96184 4 CoreFoundation 0x0000000186c2d078 0013A8B1-2524-3534-B5BA-681AAF18C798 + 196728 5 CoreFoundation 0x0000000186c2cef0 _CF_forwarding_prep_0 + 96 6 Foundation 0x00000001858b8d8c E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 753036 7 Foundation 0x00000001858b7fc8 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 749512 8 Foundation 0x00000001858b7220 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 746016 9 Foundation 0x00000001858b70d8 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 745688 10 libxpc.dylib 0x00000002119f1a50 527F7127-9586-32C8-9D8B-2972D39EAD7A + 72272 11 libxpc.dylib 0x00000002119f35cc 527F7127-9586-32C8-9D8B-2972D39EAD7A + 79308 12 libdispatch.dylib 0x000000010160a638 _dispatch_client_callout4 + 20 13 libdispatch.dylib 0x0000000101627eac _dispatch_mach_msg_invoke + 512 14 libdispatch.dylib 0x000000010161226c _dispatch_lane_serial_drain + 352 15 libdispatch.dylib 0x0000000101628ea4 _dispatch_mach_invoke + 492 16 libdispatch.dylib 0x000000010161226c _dispatch_lane_serial_drain + 352 17 libdispatch.dylib 0x0000000101613290 _dispatch_lane_invoke + 460 18 libdispatch.dylib 0x00000001016206fc _dispatch_root_queue_drain_deferred_wlh + 328 19 libdispatch.dylib 0x000000010161fd0c _dispatch_workloop_worker_thread + 580 20 libsystem_pthread.dylib 0x0000000211998680 _pthread_wqthread + 288 21 libsystem_pthread.dylib 0x0000000211996474 start_wqthread + 8 ) *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'DocumentManager service tried to send a message to a deallocated host proxy' Steps to Reproduce Present a UIDocumentPickerViewController inside a custom UIViewController. Dismiss the parent UIViewController before UIDocumentPickerViewController is fully visible. Swipe down or press the “Cancel” button in the picker. Occasionally, the system forcefully terminates the view service, causing a crash. Workarounds Tried (Unsuccessful) Using UIAdaptivePresentationControllerDelegate – Not Called for UIDocumentPickerViewController. Using viewDidDisappear to clean up – Not Called when the system terminates the picker. Forcing dismissal before presenting a new picker Reference to Line 42 in DOCRemoteViewController.m From the error traceback, we see a reference to DOCRemoteViewController.m line 42, which strongly suggests that UIDocumentPickerViewController relies on a background process to manage its lifecycle. Since we don’t have access to Apple’s private code, we assume that the DocumentManager service is trying to send a message to an already deallocated instance of UIDocumentPickerViewController, leading to a crash. One of the example wrapper implementation of us: class DocumentPickerViewController: UIViewController, UIDocumentPickerDelegate { private var picker: UIDocumentPickerViewController? weak var delegate: UIDocumentPickerDelegate? override func viewDidLoad() { super.viewDidLoad() print("📄 DocumentPickerViewController - viewDidLoad() called") setupDocumentPicker() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) print("📄 DocumentPickerViewController - viewDidAppear() called") } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) print("📄 DocumentPickerViewController - viewWillAppear() called") } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) print("📄 DocumentPickerViewController - viewWillDisappear() called") } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) print("📄 DocumentPickerViewController - viewDidDisappear() called") } deinit { print("🗑 DocumentPickerViewController - deinit() called") } // MARK: - Setup Document Picker private func setupDocumentPicker() { picker = UIDocumentPickerViewController(forOpeningContentTypes: [.pdf]) picker?.delegate = self picker?.allowsMultipleSelection = false picker?.modalPresentationStyle = .formSheet if let picker = picker { present(picker, animated: false) { print("📄 Document Picker fully presented") } } } // MARK: - UIDocumentPickerDelegate Methods func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { print("✅ User selected document(s): \(urls)") delegate?.documentPicker?(controller, didPickDocumentsAt: urls) dismissSelf() } func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { print("❌ User cancelled document selection") delegate?.documentPickerWasCancelled?(controller) dismissSelf() } private func dismissSelf() { DispatchQueue.main.async { [weak self] in self?.dismiss(animated: true) } } } And logs for this implementation: 📄 Document Picker fully presented 📄 DocumentPickerViewController - viewDidAppear() called ❌ User cancelled document selection The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method} 📄 DocumentPickerViewController - viewDidLoad() called 📄 Document Picker fully presented 📄 DocumentPickerViewController - viewDidAppear() called would appreciate any workarounds from the community to prevent crashes related to this issue!
3
0
217
2w
Modifying the native selection menu ios
I am working on a React Native application where I want to modify the native text selection menu (the menu that appears when you long-press on text). Specifically, I want to add a custom option alongside the default ones like Copy, Look Up, Translate, Search Web, and Share. Is there a way to modify the native text selection menu inside a WebView on iOS? How can I add a custom menu option to the default text selection menu while keeping all the default options intact?
1
0
153
2w
App crashes when the app is moved to background
After the app is put in background for sometime and the app crashes, Some cases have the webView involvement before putting the app in to background for quite sometime and pulled into foreground. Here's the crash log information. Identifier: com.app.myapp Version: 2.3.3 (30) AppStoreTools: 16C5031b AppVariant: 1:iPhone9,1:15 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: com.app.myapp [2833] Date/Time: 2024-12-12 17:30:57.4489 +0100 Launch Time: 2024-12-12 17:04:19.7290 +0100 OS Version: iPhone OS 15.5 (19F77) Release Type: User Baseband Version: 9.61.00 Report Version: 104 **Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x000000018f1358e0 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Terminating Process: exc handler [82527] Triggered by Thread: 10 Kernel Triage: VM - Fault hit memory shortage** Thread 10 Crashed: 0 WebKit 0x000000018f1358e0 WTFCrashWithInfo(int, char const*, char const*, int) + 20 (Assertions.h:732) 1 WebKit 0x000000018f72e348 WebKit::allDataStores() + 72 (WebsiteDataStore.cpp:100) 2 WebKit 0x000000018f72e278 WebKit::WebsiteDataStore::forEachWebsiteDataStore(WTF::Function<void (WebKit::WebsiteDataStore&)>&&) + 24 (WebsiteDataStore.cpp:107) 3 WebKit 0x000000018f67c440 WebKit::WebProcessPool::updateProcessAssertions() + 52 (WebProcessPool.cpp:1773) 4 WebKit 0x000000018f684508 WebKit::WebProcessProxy::didSetAssertionType(WebKit::ProcessAssertionType) + 880 (Function.h:82) 5 WebKit 0x000000018f5bfdd0 WebKit::ProcessThrottler::setAssertionType(WebKit::ProcessAssertionType) + 712 (ProcessThrottler.cpp:148) 6 WebKit 0x000000018f5bf9b4 WebKit::ProcessThrottler::updateAssertionIfNeeded() + 408 (ProcessThrottler.cpp:176) 7 WebKit 0x000000018f5c42b0 WebKit::ProcessThrottler::Activity<(WebKit::ProcessThrottler::ActivityType)1>::Activity(WebKit::ProcessThrottler&, WTF::ASCIILiteral) + 76 (ProcessThrottler.cpp:58) 8 WebKit 0x000000018f659958 WebKit::WebPageProxy::runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, std::__1::optional<WTF::ObjectIdentifierWebCore::FrameIdentifierType >, API::ContentWorld&, WTF::Comple... + 240 (ProcessThrottler.h:66) 9 WebKit 0x000000018f3ca7cc -[WKWebView _evaluateJavaScript:asAsyncFunction:withSourceURL:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:] + 1352 (WKWebView.mm:1151) 10 WebKit 0x000000018f131700 -[WKWebView evaluateJavaScript:completionHandler:] + 120 (WKWebView.mm:896) 11 MyApp 0x00000001044e7e64 cli_signalHandler + 2420 12 MyApp 0x00000001044e4470 getExtraInfoId + 132792 13 MyApp 0x00000001044c2b18 CLI_Reset + 50684 14 MyApp 0x00000001044c2a18 CLI_Reset + 50428 15 MyApp 0x00000001044c1cec CLI_Reset + 47056 16 MyApp 0x00000001044c27e8 CLI_Reset + 49868 17 MyApp 0x00000001044e01f4 getExtraInfoId + 115772 18 MyApp 0x0000000104492498 StringToScreenDensityLevel + 4588 19 libdispatch.dylib 0x0000000180e80094 _dispatch_client_callout + 16 (object.m:560) 20 libdispatch.dylib 0x0000000180e22bb8 _dispatch_continuation_pop$VARIANT$mp + 440 (inline_internal.h:2622) 21 libdispatch.dylib 0x0000000180e348dc _dispatch_source_invoke$VARIANT$mp + 1668 (source.c:596) 22 libdispatch.dylib 0x0000000180e22730 _dispatch_queue_override_invoke + 424 (queue.c:0) 23 libdispatch.dylib 0x0000000180e2fb94 _dispatch_root_queue_drain + 340 (inline_internal.h:0) 24 libdispatch.dylib 0x0000000180e3039c _dispatch_worker_thread2 + 172 (queue.c:6935) 25 libsystem_pthread.dylib 0x00000001dc483dd4 _pthread_wqthread + 224 (pthread.c:2612) 26 libsystem_pthread.dylib 0x00000001dc48393c start_wqthread + 8 (:-1) Thread 10 crashed with ARM Thread State (64-bit): x0: 0x0000000000000064 x1: 0x000000018fad60a0 x2: 0x000000018fad6189 x3: 0x0000000000000113 x4: 0x0000000000000030 x5: 0x0000000100000030 x6: 0x0000000000000000 x7: 0x0000000000000001 x8: 0x000000016fd6b000 x9: 0x0000000106dd4580 x10: 0x000000000000002c x11: 0x0000000000020408 x12: 0x0000000000080000 x13: 0x0000000000000000 x14: 0x0000020000011000 x15: 0x0000000100000000 x16: 0x00000001dc48425c x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x000000016fd6a418 x20: 0x0000000282ece080 x21: 0x00000002834ac2a0 x22: 0x00000001f694c000 x23: 0x0000000117004a80 x24: 0x0000000283bb6558 x25: 0x000000011a00a1d8 x26: 0x0000000000000000 x27: 0x0000000000000002 x28: 0x000000016fd6b180 fp: 0x000000016fd6a3d0 lr: 0x000000018f72e348 sp: 0x000000016fd6a3b0 pc: 0x000000018f1358e0 cpsr: 0x60000000 esr: 0xf200c471 (Breakpoint) pointer authentication trap IB
2
0
158
2w
Extending iOS screen to an external display
I understand two key concepts from desktop platforms: Screen Mirroring – The same content is displayed on both the primary and external screens. Screen Extension – The external display shows different content that complements what's on the main screen. My question pertains to the second point: Is it possible to extend the display on iOS and iPadOS devices? I'm referring to this Apple documentation, which explains how to extend content from an iOS/iPadOS device to an external display. I tested this in a sample iOS Xcode project. In the iOS Simulator, I was able to detect an "external display" and present a separate UIWindow on it. However, when I tried the same on a real device (iPhone 15 connected to a MacBook Pro via cable), the external display connection was not detected. I’d like to confirm whether screen extension is possible on a real iOS device. From my research, it appears that extension is only supported on iPadOS via Stage Manager, but I want to verify if there’s any way to achieve this on an iPhone. If so, are there any known apps that currently utilize extended display functionality on iOS? If extension is not possible on iOS, what does the documentation mentions iOS?
1
0
143
2w