Post AP4wEfaSvCsCPtEzHE by Sanguish@mastodon.social
(DIR) More posts by Sanguish@mastodon.social
(DIR) Post #AP4sdvvuswN6XH47P6 by shadowfacts@social.shadowfacts.net
2022-10-30T01:36:24.826105Z
0 likes, 0 repeats
So I've run into a weird interaction between UIKit and macOS*. In the attached code, the first log statement is printed when the menu containing the UIDeferredMenuElement is shown. But the second two aren't executed until after the menu is closed. On iOS, this behaves as expected and the logs are printed basically immediately.I think this is happening because showing the AppKit menu suspends the main runloop (because it enters its own nested runloop?) while the menu is open.So anything that relies on the main runloop (say, Swift async stuff that runs on the MainActor) can't be used in deferred menu elements on macOS.I'm not sure there's anything I can do to work around this? Beyond rewriting this to not use async Swift.*This isn't specific to Catalyst, it happens in "iOSMac" apps too, since they also convert UIKit menus to Mac ones.Swift code that creates UIDefer…
(DIR) Post #AP4skjdkzKagR9oZge by shadowfacts@social.shadowfacts.net
2022-10-30T01:37:38.943114Z
0 likes, 0 repeats
h/t @dgoldsmith, whose bug report turned me on to this
(DIR) Post #AP4tUu2sdNEm1ra3Bw by dgoldsmith@mastodon.social
2022-10-30T01:41:55Z
0 likes, 0 repeats
@shadowfacts I think it would be a good idea to file a bug report with Apple. It’s hard to believe this is the intended behavior.
(DIR) Post #AP4tUuRh975RGpBrs0 by shadowfacts@social.shadowfacts.net
2022-10-30T01:45:59.032272Z
0 likes, 0 repeats
@dgoldsmith indeed, I am presently writing one up
(DIR) Post #AP4viA0en5x5DJzRD6 by shadowfacts@social.shadowfacts.net
2022-10-30T02:10:47.945965Z
0 likes, 0 repeats
FB11732116, for those whom it may concern
(DIR) Post #AP4vskhZE23luN6yAa by shadowfacts@social.shadowfacts.net
2022-10-30T02:12:42.628935Z
0 likes, 0 repeats
@drahardja would that you were still at apple, because this seems like it's right up your corner of things 😜
(DIR) Post #AP4wEfaSvCsCPtEzHE by Sanguish@mastodon.social
2022-10-30T02:10:53Z
0 likes, 0 repeats
@dgoldsmith @shadowfacts there were issues with macOS and swift concurrency in Xcode 14.0.1 I think. I don’t know if this would be caused by that because catalyst.I’d try on 14.1rc2 and see if that fixes it.
(DIR) Post #AP4wEgAcklnSE29rdY by shadowfacts@social.shadowfacts.net
2022-10-30T02:16:40.245766Z
0 likes, 0 repeats
@Sanguish @dgoldsmith this is on 14.1 (though I missed that there was a second RC), but I'm 99% sure it's unrelated to Swift concurrency since it's readily reproducible with just the DispatchQueue.main.async
(DIR) Post #AP4wNqa7PjgZ7aSFEW by Sanguish@mastodon.social
2022-10-30T02:17:22Z
1 likes, 0 repeats
@shadowfacts @dgoldsmith yup, definitely radar worthy the n
(DIR) Post #AP55YRn8p1on0efvNI by drahardja@mastodon.social
2022-10-30T03:52:25Z
1 likes, 0 repeats
@shadowfacts That is correct. Menus in AppKit spins its own modal runloop, so dispatch-async’ing to the main runloop will not get the block scheduled until the context menu is dismissed.
(DIR) Post #AP55bKUYQ2JDEqM6kq by shadowfacts@social.shadowfacts.net
2022-10-30T04:01:37.149606Z
0 likes, 0 repeats
oh wait, I actually can't work around this. even without using Swift concurrency, I still need to dispatch back to the main queue in order to call the elementHandler closure that UIDeferredMenuElement gives my closure. and I don't have any way of getting back to the main queue once I leave it
(DIR) Post #AP55h2f5cj4pg20WK8 by shadowfacts@social.shadowfacts.net
2022-10-30T04:02:39.391341Z
0 likes, 0 repeats
so actually UIDeferredMenuElement is just entirely broken on Ventura? I think this worked on Monterey, thoughtime to go test and update my feedback...
(DIR) Post #AP55pTluiGIE4eDr4S by dgoldsmith@mastodon.social
2022-10-30T04:00:21Z
1 likes, 0 repeats
@drahardja @shadowfacts :sadness:
(DIR) Post #AP56PuqHXj2sSMdk0W by shadowfacts@social.shadowfacts.net
2022-10-30T04:10:45.182065Z
0 likes, 0 repeats
nope, it's also broken on Monterey
(DIR) Post #AP56Rhuia7Y2wGZLpg by shadowfacts@social.shadowfacts.net
2022-10-30T04:11:05.430960Z
0 likes, 0 repeats
so I guess following people is going to remain brokensorry to the two (2) people who use Tusker on macOS :/
(DIR) Post #AP6idyDrlKCGPXlBI0 by dgoldsmith@mastodon.social
2022-10-30T21:08:27Z
0 likes, 0 repeats
@shadowfacts I’m working around it by “open in Safari” and then following there, but it’s really annoying.
(DIR) Post #AP6idyaCQI3rWoD16G by shadowfacts@social.shadowfacts.net
2022-10-30T22:53:47.427266Z
0 likes, 0 repeats
@dgoldsmith I do actually have a sort of workaround in the next build, but it's not perfectit'll use the cached network data if available, but it may not be, in which case it'll still show the "Loading..." item
(DIR) Post #AP6sGlfXGmg0MEHEwa by dgoldsmith@mastodon.social
2022-10-31T00:41:11Z
1 likes, 0 repeats
@shadowfacts It works!! 🙏🏻