Error when clicking on TextField : CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them

Hello, I face an error everytime I want to interact with a TextField. The XCode debug area is showing :

CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them

There is no crash, and the text field is working fine.

I am developing for MacOS using a macbook pro Intel from 2019 with Sonoma 14.5 and Xcode 15.4 and I think that I noticed since the release of Sonoma. I was not particularly concerned by it but I noticed that interacting with the textField was leading to severe hang in my app, and micro-hang in the test app and I am wondering is these two issues could be related.

The message is easy to reproduce. Just create a new Project/Application/App using SwiftUI and add a TextField to the ContentView. When you start app, click or double click on the text field, enter a message and press enter.


import SwiftUI

struct ContentView: View {
    @State var value: String = ""
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
            TextField(text: $value, 
                      label: {
                Text("Test")
            }
            )
        }
        .padding()
    }
}

Did you notice the same thing ? How I could solve it ?

Note : I already posted the problem on Swift forums but it was close because related to SwiftUI https://forums.swift.org/t/error-when-clicking-on-textfield-client-error-tuinsremoteviewcontroller-does-not-override-viewservicedidterminatewitherror-and-thus-cannot-react-to-catastrophic-errors-beyond-logging-them/72134/1

Thank you

Answered by DTS Engineer in 790190022

I've tried running the app you provided for macOS, and I'm unable to replicate the error you're encountering in the output window. The mention of 'TUINSRemoteViewController' from UIKit catches my eye, as it seems out of place in a SwiftUI application.

Could you please provide the following additional information?

  1. Full output window messages: It would be very helpful to see the complete error logs.

  2. Screenshots or gifs: If the error is visual, screenshots or gifs could aid in understanding the issue.

  3. Environmental details: What version of macOS are you using? Any specific Xcode settings or configurations?

  4. Test project with focused issue: It would be greatly appreciated if you could create a minimal test project that recreates the problem. To make it easier for me to investigate, please ensure that the project:

    • Is focused on the specific task or view where the error occurs.
    • Includes the necessary assets and dependencies.
    • Provides clear instructions on how to run the project and reproduce the error.

You can upload the project to a file-sharing service like GitHub or Dropbox and share the link here.

Thank you for your detailed assistance! The more information you provide, the faster I can help you resolve this issue.

struct ContentView: View {
    @State var value: String = ""
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")

            TextField(text: $value,
                                  label: {
                            Text("Test")
                        }
                        )

        }
        .padding()
    }
}

I have a simple SwiftUI View with two TextFields. When I run the app from Xcode and click in either of the TextFields I get the "beachball" for 5 or 10 seconds and then the cursor appears in the filed and the field has the blue highlight surrounding it. I see the "CLIENT ERROR: TUINS...." message in the console. Very annoying and puzzling.

I've tried running the app you provided for macOS, and I'm unable to replicate the error you're encountering in the output window. The mention of 'TUINSRemoteViewController' from UIKit catches my eye, as it seems out of place in a SwiftUI application.

Could you please provide the following additional information?

  1. Full output window messages: It would be very helpful to see the complete error logs.

  2. Screenshots or gifs: If the error is visual, screenshots or gifs could aid in understanding the issue.

  3. Environmental details: What version of macOS are you using? Any specific Xcode settings or configurations?

  4. Test project with focused issue: It would be greatly appreciated if you could create a minimal test project that recreates the problem. To make it easier for me to investigate, please ensure that the project:

    • Is focused on the specific task or view where the error occurs.
    • Includes the necessary assets and dependencies.
    • Provides clear instructions on how to run the project and reproduce the error.

You can upload the project to a file-sharing service like GitHub or Dropbox and share the link here.

Thank you for your detailed assistance! The more information you provide, the faster I can help you resolve this issue.

struct ContentView: View {
    @State var value: String = ""
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")

            TextField(text: $value,
                                  label: {
                            Text("Test")
                        }
                        )

        }
        .padding()
    }
}

Hello, and thank you for your quick reply.

Workflow:

I created a new project without changing any build settings. I've created two projects and uploaded them to Google Drive so build settings can be verified: https://drive.google.com/file/d/1hhnG_J005EpuViR8JLWytj5CfpyjcJfh

I've also recorded two videos demonstrating the issue:

The error occurs when I interact with a single text field and then go out of focus: https://youtu.be/8hJOcwhkH_Y

The error occurs every time I switch between two independent text fields: https://youtu.be/C-eZUULWywA

These projects are included in the Google Drive archive linked above. Additionally, the videos are available on Google Drive if that's more convenient: https://drive.google.com/drive/folders/1XpJQgfHoiEk5T_RXJiQkervhfDRUknsF?usp=sharing

I am using Xcode 16 in these videos, but the issue also occurs with Xcode 15.4.

Summary of Your Request:

  1. Log Output with Two Text Fields:
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
  1. Workflow Videos: Video 1 : https://youtu.be/8hJOcwhkH_Y Video 2 : https://youtu.be/C-eZUULWywA

  2. Environment: - macOS Version: Sonoma 14.5 - Hardware: 2019 MacBook Pro, Intel 8-Core i9 - Xcode Version: Xcode 16 (also tested with Xcode 15.4)

  3. Test Projects: Test Projects on Google Drive : https://drive.google.com/file/d/1hhnG_J005EpuViR8JLWytj5CfpyjcJfh

Thank you for your assistance! If you need more information feel free to tell.

I'm getting this as well. I thought it was because I was doing something complicated with a TextField in a sheet but the example from AymericF does it for me as well. MacOS only, Sonoma 14.6, Xcode Version 15.4 (15F31d)

Both my son and I hit this every day on different projects. Nothing in NSViewController.h even returns a NSError, so I am really puzzled about what I'm missing. But yes, it does seem to be related to interacting with a NSTextField.

MacOS 14.5 23F79, Xcode 15.4 Mac App

I was able to get it to stop at or about the point the error is emitted by breaking on _os_log_fault_impl. The code path is triggered when I clicked in a NSTextField shortly after (my) app launch without doing anything else. The text field is empty. os_log_fault gave this backtrace:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 18.1
  * frame #0: 0x0000000194b383c8 libsystem_trace.dylib`_os_log_fault_impl
    frame #1: 0x000000019d6ad0bc ViewBridge`-[NSRemoteViewControllerAuxiliary viewDidInvalidate:].cold.2 + 92
    frame #2: 0x000000019d692e7c ViewBridge`-[NSRemoteViewControllerAuxiliary viewDidInvalidate:] + 452
    frame #3: 0x000000019d6675e0 ViewBridge`-[NSRemoteView invalidate] + 284
    frame #4: 0x000000024f39b0dc TextInputUIMacHelper`-[TUINSWindow setRemoteViewController:] + 128
    frame #5: 0x000000024f39c12c TextInputUIMacHelper`__36-[TUINSCursorUIController activate:]_block_invoke.120 + 272
    frame #6: 0x000000019d692c04 ViewBridge`-[NSRemoteViewControllerAuxiliary viewDidAdvanceToRunPhase:] + 56
    frame #7: 0x000000019d67cffc ViewBridge`-[NSRemoteView _lastCallImpliedByAdvancingToPhase:] + 228
    frame #8: 0x0000000194ea2694 CoreFoundation`__invoking___ + 148
    frame #9: 0x0000000194ea2514 CoreFoundation`-[NSInvocation invoke] + 428
    frame #10: 0x000000019d612be8 ViewBridge`__deferNSXPCInvocationOntoMainThread_block_invoke + 120
    frame #11: 0x000000019d607eb4 ViewBridge`__wrapBlockWithVoucher_block_invoke + 56
    frame #12: 0x000000019d6a7a78 ViewBridge`deferredBlockOpportunity_block_invoke_2 + 360
    frame #13: 0x0000000194ec2070 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
    frame #14: 0x0000000194ec1f84 CoreFoundation`__CFRunLoopDoBlocks + 356
    frame #15: 0x0000000194ec1414 CoreFoundation`__CFRunLoopRun + 2440
    frame #16: 0x0000000194ec0434 CoreFoundation`CFRunLoopRunSpecific + 608
    frame #17: 0x000000019f66419c HIToolbox`RunCurrentEventLoopInMode + 292
    frame #18: 0x000000019f663fd8 HIToolbox`ReceiveNextEventCommon + 648
    frame #19: 0x000000019f663d30 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
    frame #20: 0x000000019871fd68 AppKit`_DPSNextEvent + 660
    frame #21: 0x0000000198f15808 AppKit`-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
    frame #22: 0x00000001991080a0 AppKit`-[NSTextView _bellerophonTrackMouseWithMouseDownEvent:originalSelection:granularity:extending:rectangular:toggling:multiple:checkForLink:autoscrollEvent:] + 856
    frame #23: 0x0000000198a32264 AppKit`-[NSTextView mouseDown:] + 3104
    frame #24: 0x00000001989c0cb0 AppKit`-[NSTextField mouseDown:] + 280
    frame #25: 0x00000001988c0dcc AppKit`-[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3472
    frame #26: 0x000000019884c40c AppKit`-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 288
    frame #27: 0x000000019884c118 AppKit`-[NSWindow(NSEventRouting) sendEvent:] + 284
    frame #28: 0x0000000198f14828 AppKit`-[NSApplication(NSEventRouting) sendEvent:] + 1604
    frame #29: 0x0000000198b6289c AppKit`-[NSApplication _handleEvent:] + 60
    frame #30: 0x00000001987130c0 AppKit`-[NSApplication run] + 512
    frame #31: 0x00000001986ea2e0 AppKit`NSApplicationMain + 880
    frame #32: 0x000000010222389c MechanusBRP`main(argc=3, argv=0x000000016dbff3c0) at main.m:15:12
    frame #33: 0x0000000194a5a0e0 dyld`start + 2360
(lldb) c
Process 24764 resuming
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them

My assumption here is that we are doing something wrong (e.g. overlapping views or maybe some method is not wired up that needs to be, or didn't set up something in the controller hierarchy that we should have, etc.) The problem is that the warning seems geared towards Apple internal development and the rest of us are just left scratching our head wondering what this could be about. So if nothing else, perhaps an engineer might gaze lovingly at the error message and see if it could perhaps be made to be a bit more helpful. A few hints dropped here would be lovely as well so we could move forward with whatever it is we forgot to wire up.

FWIW: I don't think choice of language is relevant here. We see it in a pair of objc++ apps. It also doesn't seem to matter about display. I see it with my MBP M1 clamshell closed on an Apple Studio display. My son sees it on a MBP M3 clamshell open on the onboard display. I haven't looked at other configurations. (Both are HDR displays though. Clearly you need HDR display for "testing"! Contact your manager.)

I was able to verify the above backtrace is really the offending log:

(lldb) po $x0
6935281664
(lldb) po $x1
<OS_os_log: 0x12b7acdc0>
(lldb) po $x2
17
(lldb) po $x3
6936223887
(lldb) po $x4
6157865216
(lldb) po $x5
22
(lldb) po $x6
6149505024
(lldb) po $x7
1
(lldb) x/s $x3
0x19d6e608f: "CLIENT ERROR: %@ does not override -%@ and thus cannot react to catastrophic errors beyond logging them"
(lldb) x/22bx $x4
0x16f099100: 0x02 0x02 0x40 0x08 0x50 0x7a 0x21 0x6e
0x16f099108: 0x02 0x00 0x00 0x00 0x40 0x08 0x50 0xef
0x16f099110: 0x66 0x2f 0x01 0x00 0x00 0x00
(lldb) po 0x000000012f66ef50
viewServiceDidTerminateWithError:
(lldb) po 0x000000026e217a50
TUINSRemoteViewController

Hello, I've been encountering this issue with TextField with SwiftUI for macOS development. I am using macOS Sonoma 14.5 with Xcode 15.4 and get the same error.

CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them

Has anyone found the cause or solution for this yet? Thanks.

Same. I'm running Sonoma 14.5 on a 2021 Apple M1 Pro and get this message in Xcode every time I click on the text field in the simple box.

My entire app is:

import SwiftUI

@main struct SwiftUITestApp: App { var body: some Scene { WindowGroup { ContentView() } } }

With a ContentView.swift of:

import SwiftUI

struct ContentView: View { @State private var name: String = "" @State private var greeting: String = ""

var body: some View {
    VStack {
        TextField("Enter your name", text: $name)
            .padding()
            .textFieldStyle(RoundedBorderTextFieldStyle())
        Button(action: {
            greeting = "Hello, \(name)!"
        }) {
            Text("Greet")
                .padding()
                .background(Color.blue)
                .foregroundColor(.white)
                .cornerRadius(4)
        }
        Text(greeting)
            .padding()
            .font(.largeTitle)
    }
    .padding()
}

}

struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }

I spent three days tracking this bizarre one down, besides the Error message - NSTextView's started not drawing any text. No code changes had happened other than moving to Xcode 15.4 and Sonoma. The problem didn't happen with Xcode 14 and Sonoma. XCode 15.4 and Ventura work. Hows that for a puzzle? It turns out the problem was a change that Apple made to NSView in MacOS 14. The bug was caused when Apple decided to change the default return value of NSView.clipsToBounds. By setting that to true the code works again and the Error message is gone. Here's an explanation -

https://developer.apple.com/documentation/macos-release-notes/appkit-release-notes-for-macos-14#NSView

@KMacTexas

I would say the OP's problem was this error log record: "CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them"

I tried your suggestion and in this case it has no effect, the mentioned error log is still being generated.

TextField("Enter your text for printing ...", text: $textProperty.text).introspect(.textField, on: .macOS(.v14, .v15)) { view in
  view.clipsToBounds = true
}

same here. macOS 14.5, MacBook Pro M3 I can create some records (SwiftData) - and then, it crashes when I click into the first field of the new created record. Filling in one of the other TextFields seems to work, editing the record afterwards seems to work fine

after posting my answer, I spent some more time on that

  • I had no crashes under the iPhone simulator
  • same app started as 'on my Mac', crashes after 3 or 4 new records

Since I didn't had crashes when creating new records via sheet (2 empty TextFields and a button to create that record), I did the following:

  • in my model, I initialized two fields with a string (before, I initalized the fields with empty strings ("")), "Title..." and "Author...".

(title was the first field, clicking into that forced the crash)

After this change, I created about 12 records, no crash!

Hope that was the solution! Means that the empty string/attribute was the problem

It seems like this is a known bug, can you please report it using the Feedback Assistant. Don't forget to include the error messages, reproducible steps, and if possible, the project that is causing the issue. Once you open the bug report, please post the FB number here for my reference.

If you have any questions about filing a bug report, take a look at Bug Reporting: How and Why?

I am able to reproduce this bug by attaching a textField into accessory view of NSSavePanel + trying to press enter.

Once you move focus to the textfield and try to press enter it will print CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them

PS: Pressing enter from accessory view worked flawlessly in macOS Ventura and below.

class ViewController: NSViewController, NSTextFieldDelegate, NSControlTextEditingDelegate {

    let savePanel = NSSavePanel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let customView = NSView()
        let textField = NSTextField(string: "11111111")
        textField.delegate = self // to get focus using tab keypress
        savePanel.accessoryView = textField
    }
    
    override func viewWillAppear() {
        savePanel.runModal()
    }

}

The issue seems of wider impact than just with text fields. DTS Engineer could you provide some clues so we can try to work around the problem while Apple tracks it down?

Error when clicking on TextField : CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
 
 
Q