Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSettings() from CXCallDirectoryManager stopped working in .NET 8.0 for iOS #21008

Closed
thomas-cas opened this issue Aug 9, 2024 · 4 comments · Fixed by #21011
Closed

OpenSettings() from CXCallDirectoryManager stopped working in .NET 8.0 for iOS #21008

thomas-cas opened this issue Aug 9, 2024 · 4 comments · Fixed by #21011
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@thomas-cas
Copy link

We have a iOS app that we recently migrated from Xamarin.iOS to .NET 8.0 for iOS. After this update opening the "Call Blocking & Identification" settings on the iOS device stopped working.

https://developer.apple.com/documentation/callkit/cxcalldirectorymanager/opensettings(completionhandler:)

Steps to Reproduce

Call OpenSettings() somewhere in the app like this:

CXCallDirectoryManager.SharedInstance.OpenSettings(_ => { }));

Expected Behavior

The phone's "Call Blocking & Identification" settings should be opened.

Actual Behavior

This fails since the update and nothing happens when calling it.

For testing I built a blank native Swift app just calling OpenSettings() when pressing a button and here the phone correctly navigates to the caller id settings page.

Logs

The NSError I get in the .NET version is the follwing:

Couldn’t communicate with a helper application.
Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.CallKit.CallDirectory" UserInfo={NSDebugDescription=connection to service named com.apple.CallKit.CallDirectory}

And the MacOS console logs the follwing information:

11:53:06.692184+0200	OpenSettingsTest	[0x1014066c0] activating connection: mach=false listener=false peer=false name=com.apple.CallKit.CallDirectory
11:53:06.692260+0200	OpenSettingsTest	[0x1014066c0] activating connection: mach=false listener=false peer=false name=com.apple.CallKit.CallDirectory
11:53:06.693727+0200	OpenSettingsTest	error Error Domain=NSCocoaErrorDomain Code=4097 UserInfo={NSDebugDescription=<private>}
11:53:06.693664+0200	OpenSettingsTest	error Error Domain=NSCocoaErrorDomain Code=4097 UserInfo={NSDebugDescription=<private>}
11:53:06.699024+0200	OpenSettingsTest	[0x1014066c0] Re-initialization successful; calling out to event handler with XPC_ERROR_CONNECTION_INTERRUPTED
11:53:06.699157+0200	OpenSettingsTest	Default connection interrupted for call directory manager <private>
11:53:06.699317+0200	OpenSettingsTest	[0x1014066c0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
11:53:06.699461+0200	OpenSettingsTest	Default connection invalidated for call directory manager <private>
11:53:06.698939+0200	OpenSettingsTest	[0x1014066c0] Re-initialization successful; calling out to event handler with XPC_ERROR_CONNECTION_INTERRUPTED
11:53:06.699095+0200	OpenSettingsTest	Default connection interrupted for call directory manager <private>
11:53:06.699234+0200	OpenSettingsTest	[0x1014066c0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
11:53:06.699399+0200	OpenSettingsTest	Default connection invalidated for call directory manager <private>
@rolfbjarne
Copy link
Member

I can reproduce, and the device log also shows:

com.apple.CallKit.CallDirectory(Foundation)[33060] <Fault>: <NSXPCConnection: 0x115d0c2a0> connection from pid 33189 on anonymousListener or serviceListener received an undecodable message (incompatible reply block signature for launchCallDirectorySettingsWithReply: (wire: <NSMethodSignature: 0x115f06750>
    number of arguments = 3
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (v) 'v'
        flags {}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 0, size adjust = 0}
        memory {offset = 0, size = 0}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@?'
        flags {isObject, isBlock}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (^) '^v'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 2: -------- -------- -------- --------
        type encoding ({) '{NativeHandle=^v}'
        flags {isStruct}
        modifiers {}
        frame {offset = 16, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
            type encoding (^) '^v'
            flags {}
            modifiers {}
            frame {offset = 16, offset adjust = 0, size = 8, size adjust = 0}
            memory {offset = 0, size = 8}
 vs local: <NSMethodSignature: 0xa911206d62b9baa7>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (v) 'v'
        flags {}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 0, size adjust = 0}
        memory {offset = 0, size = 0}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@?'
        flags {isObject<\M-b\M^@\M-&>)

This looks like Apple is validating a bit too much :/ We might have to come up with some sort of workaround here.

I haven't tried this, but I suspect that if you create a tiny Objective-C library that calls this method it'll work.

@rolfbjarne rolfbjarne added this to the Future milestone Aug 9, 2024
@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Aug 9, 2024
rolfbjarne added a commit that referenced this issue Aug 9, 2024
Pending:

* Tests
* Better description.

Fixes #21008.
@rolfbjarne
Copy link
Member

This looks like Apple is validating a bit too much :/ We might have to come up with some sort of workaround here.

Never mind, this is a bug on our side. Fix is in progress.

vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Aug 15, 2024
rolfbjarne added a commit that referenced this issue Aug 21, 2024
…tures. Fixes #21008. (#21048)

When we compute the signature of a block for Objective-C, we need to use parameters of the user-provided callback (and not the intermediate UnmanagedCallersOnly method) to compute the signature.

This is because the intermediate method's parameters don't have all the information we need to correctly compute the block signature (in particular for the issue in question, the user callback has an `NSError` parameter, while the intermediate method has an `IntPtr` parameter, and these two parameter types show up differently in the block signature).

This is solved by adding the `UserDelegateType` attribute (which was created for exactly this, and it's just in older generated code) to the intermediate method, pointing to a delegate with the correct managed signature.

Fixes #21008.

Backport of #21011
@AzizBelAbed
Copy link

@rolfbjarne Thanks for taking care, I'm facing the same issue on .NET MAUI iOS.
Any idea when this fix will be available ?

@rolfbjarne
Copy link
Member

@rolfbjarne Thanks for taking care, I'm facing the same issue on .NET MAUI iOS. Any idea when this fix will be available ?

It will be included in our next service release (which should be within a few weeks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants