libusbmuxd icon indicating copy to clipboard operation
libusbmuxd copied to clipboard

usbmuxd_subscribe call back didn't call

Open piaojin opened this issue 4 years ago • 14 comments

I try to call usbmuxd_subscrib: int res = usbmuxd_subscribe(usbmux_event_cb, NULL); And res = 0, but won't call usbmux_event_cb. 'usbmuxd_events_subscribe' API has the same issue.

static void usbmux_event_cb(const usbmuxd_event_t *event, void *user_data) {

}

Xcode 11.4 MacOS 10.15.4

piaojin avatar May 16 '20 12:05 piaojin

I found "device_monitor" didn't call. The debug code is "USBMUXD_API int usbmuxd_events_subscribe(usbmuxd_subscription_context_t *ctx, usbmuxd_event_cb_t callback, void *user_data)" line "int res = thread_new(&devmon, device_monitor, NULL);". image

piaojin avatar May 16 '20 14:05 piaojin

I have updated libimobiledevice, libplist, libusbmuxd, openssl and usbmuxd to the lastest version.

piaojin avatar May 16 '20 15:05 piaojin

What are you doing after calling usbmuxd_subscribe? Remember this runs in a new thread so if you don't wait in the main thread (or the thread you call usbmuxd_subscribe from) it won't get a chance to call the callback function.

nikias avatar May 16 '20 15:05 nikias

@nikias I call usbmuxd_subscribe in the main thread. And I just updated libimobiledevice, libplist, libusbmuxd, openssl and usbmuxd to the lastest version.

piaojin avatar May 16 '20 16:05 piaojin

@nikias This is MacApp demo. Call usbmuxd_subscribe in applicationDidFinishLaunching. And the callback function "usbmux_event_cb" didn't be called. MacDemo.zip

piaojin avatar May 16 '20 16:05 piaojin

Hmm maybe it can't connect to /var/run/usbmuxd socket file? Also you are using static libs which is not really what LGPL license was meant for.

nikias avatar May 16 '20 21:05 nikias

Oh actually you said device_monitor isn't called. Weird. Can you single step through usbmuxd_events_subscribe and see if it actually tries to call thread_new at all?

nikias avatar May 16 '20 21:05 nikias

@nikias I single-step debugging through usbmuxd_events_subscribe and thread_new was called. The res is 0. image

piaojin avatar May 17 '20 05:05 piaojin

Ok now break inside device_monitor here: https://github.com/libimobiledevice/libusbmuxd/blob/master/src/libusbmuxd.c#L1098 and see where it stops

nikias avatar May 17 '20 12:05 nikias

I break inside the start line of device_monitor, but the breakpoint didn't come to the start line of device_monitor. device_monitor didn't be called.

image

piaojin avatar May 17 '20 16:05 piaojin

Well I guess this is because you are linking in the libraries as static libraries. If you compile shared libraries and use those it will probably work.

nikias avatar May 29 '20 18:05 nikias

Well I guess this is because you are linking in the libraries as static libraries. If you compile shared libraries and use those it will probably work.

Thanks, I will have a try.

piaojin avatar Jun 01 '20 03:06 piaojin

@piaojin Did you solve this problem? I met it too

Glen-Bai avatar Apr 13 '21 04:04 Glen-Bai

@piaojin Did you solve this problem? I met it too

@Glen-Bai Sorry No.

piaojin avatar May 02 '21 08:05 piaojin

See my assumption above why this doesn't work. I know the code works if done properly, it's being used in a lot of projects, for example in checkra1n app.

nikias avatar Apr 22 '23 10:04 nikias