MatterSupport MatterExtension RequestHandler never triggered

Hi everyone,

I try to understand Matter Support and how to get the onboardingPayload from the commissionDevice func.

I followed the docs from https://developer.apple.com/documentation/mattersupport/adding-matter-support-to-your-ecosystem

I also added the Matter Extension, added the NSBonjourServices, included the Matter Extension and did .perform(). The UI shows up correctly and I can scan the QR-Code, which shows pair it to your ecosystem. I launched the extension via Xcode in my application, but the RequestHandler isn't triggering.

Did I miss something? Can someone point me into the right direction please?

I also added the Matter Extension, added the NSBonjourServices, included the Matter Extension and did .perform(). The UI shows up correctly and I can scan the QR-Code, which shows pair it to your ecosystem. I launched the extension via Xcode in my application, but the RequestHandler isn't triggering.

Did I miss something? Can someone point me into the right direction please?

Based on what you're describing, I suspect the issue is simply that debugging extensions is significantly more complicated than a standard application. An app extension runs as part of another "hosting" component and cannot run without that component, so you cannot simply prese "run" in Xcode and debug it.

The section "Debug, Profile, and Test Your App Extension" of the "App Extension Programming Guide" partially describes the process, however, the extension pattern in describes doesn't entirely match how the MatterSupport extension works. I think the flow described in "Debugging a Network Extension Provider" is actually what you'll want to use.

A few things I'd add/expand on here:

  • Are you sure you actually need/want a MatterSupport extension? That extension point is designed to support "ecosystem" vendors and, in fact, some of it's design choices don't make sense until you realize that the app extension is often acting as a go between to an actual controller, NOT doing direct pairing.

  • If you're simply trying to send matter commands to specific accessories, you can do that through HomeKit using the process described here.

  • Assuming you are an ecosystem and will be using the MatterSupport extension, then the next thing I would do is get the full pairing process working in a standard application. The pairing process is complicated enough that it's worth fully testing and debugging that process in a standard app context (which is trivial to debug) before you do anything with the MatterSupport extension. For simplicity, I would just hard code the setup payload of my specific test access, though you could also capture the payload yourself if you chose.

  • Related to that point, if your app uses the MatterSupport extension delegates as the "calling pattern" for it's own implementation, you can actually share exactly the same implementation between your test app and your extension, simplifying the process of actually implementing the final extension.

  • Good logging is your best debugging tool, NOT the debugger. While you can connect the debugger to your extension, the process involved is cumbersome and, more importantly, many of the stages are time restricted such that debugger delays can actually introduce failures that wouldn't otherwise exist.

The broad idea here is to do as much development/testing as possible outside of the app extension context, minimizing the need to directly debug the MatterSupport extension.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Thank you for your fast reply.

I will clarify it a bit more.

Yes, I'm sure, I will need it, as I will support an ecosystem, as you said. The Matterwebsite points you to Mattersupport.

I already created a small test app with nothing then a button to run MatterSupport in it's extension. I used the test app as host for the extension then, same like I did it for Siri or AppWidgets (should be the same flow for the Matterextension, or am I wrong). What I expected, is, that at least the init function will be triggered in the debugger, but even this isn't working. So I guess, I missed something adding the extension correctly.

PS: which standard app you had in mind?

I already created a small test app with nothing then a button to run MatterSupport in it's extension. I used the test app as host for the extension then, same like I did it for Siri or AppWidgets (should be the same flow for the Matterextension, or am I wrong).

Yes, the flow here can be very different. Pulling a quote from here:

"Using Xcode to debug an app extension is a lot like using Xcode to debug any other process, but with one important difference: In your extension scheme’s Run phase, you specify a host app as the executable. Upon accessing the extension through that specified host’s UI, the Xcode debugger attaches to the extension."

In the case above, the app is requesting an app extension to be launched and the system is maintaining a connection between the specific hosting app and the extension. The issue here is that not all of our extension (including the matter extension here) are actually hosted like this.

Some extensions, particularly our "lower level" extensions (network extensions, notification services extensions) are actually designed to be hosted by a specific system process, so that process is the only process that ever hosts them. That's what's going on here. What MatterAddDeviceRequest actually does is tell the system "please present the Matter Paring UI". The system then launches the component that creates the UI you're interacting with and THAT component is what then launches and hosts your MatterSupport extension. It's possible you might be able to get the flow above working by adding that system process as the host app (I'm honestly not sure), but what will work is to have the system present the UI (launching your MatterSupport Extension), then manually attaching using "Debug -> Attach to Process".

Note that with this flow:

What I expected, is, that at least the init function will be triggered in the debugger, but even this isn't working. So I guess, I missed something adding the extension correctly.

...you'll always "miss" your init function, as will have finished running before you're able to attach. However, in practice that shouldn't matter as the actual delegate methods are what you're actually trying to debug.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

MatterSupport MatterExtension RequestHandler never triggered
 
 
Q