Re: OS/X Java native bug
Re: OS/X Java native bug
- Subject: Re: OS/X Java native bug
- From: Saagar Jha via Cocoa-dev <email@hidden>
- Date: Fri, 17 Mar 2023 02:07:53 -0700
The implementation of -[ThreadUtilities performOnMainThreadWaiting:block:] does
the right thing here, which is calling the block directly if it’s already
running on the main thread:
https://github.com/openjdk/jdk/blob/9d518c528b11953b556aa7585fc69ff9c9a22435/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.m#L103.
It’s likely that your hang is caused by something else.
Saagar Jha
> On Mar 17, 2023, at 01:58, Michael Hall via Cocoa-dev
> <email@hidden> wrote:
>
> This was just brought to my attention on a java mailing list.
>
> An option was added to java startup options on OS/X -XstartOnFirstThread so
> the code starts on the main Appkit thread.
>
> Currently if a java Swing application starts with that option it hangs.
>
> https://bugs.openjdk.org/browse/JDK-8289573
>
> This bug indicates a regression from an earlier one…
>
> https://bugs.openjdk.org/browse/JDK-7128597
>
> For apparently pretty much the same problem it suggests…
>
>> If +[NSThread isMainThread] returns true, you can simply call your
>> initializer directly, instead of punting it onto the main thread.
>
> That from a former Apple Java Swing support person. Mike Swingler.
>
> Which resulted in a fix including…
>
>> the addition of +[NSThread isMainThread] was done at Mike's suggestion
>
> I found some old code that seems to include that fix…
>
> if ([NSThread isMainThread]) {
> [GraphicsConfigUtil _getCGLConfigInfo: retArray];
> } else {
> [GraphicsConfigUtil performSelectorOnMainThread:
> @selector(_getCGLConfigInfo:) withObject: retArray waitUntilDone: YES];
> }
>
> The current code that seems to regress to the original bug now looks like…
>
> [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
>
> With what appears to be all the code that was in the selector
> _getCGLConfigInfo following in an inline block. This always appears to run on
> main thread which I think is the reverted to bug.
>
> I’m not that familiar with code including blocks. Is there some fairly easy
> way to modify this and keep it running as an inline block but also add the
> isMainThread check to not always run on the main thread?
> Or, would you have to put it back to include the check and invocation of a
> standalone selector?
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden