Patch for review - fixes hangs when VoiceOver is active

Pete Brunet peter.brunet at oracle.com
Fri Dec 23 06:53:02 PST 2011


Kevin Miller sent me the following (slightly edited) comments when he
did the original fix...

I found the following deadlock:

1. AWT thread goes to create a new window, calls into native code
(nativeCreateNSWindow())
2. AWT thread kicks off initialization of window on AppKit thread using
[JNFRunLoop performOnMainThreadWaiting: withBlock:] passing YES as the
first parameter
3. The window initializer eventually gets to [AWTView
viewDidMoveToWindow], which calls [[self window] makeFirstResponder:self]
4. Changing the focus (first responder) triggers the native AX system,
which immediately asks for a focus update
5. JavaComponentAccessibility calls invokeAndWait() to get the AX
information from Java
6. Hang, because invokeAndWait() is waiting on the EDT to process an
event, but the EDT is waiting for the window to finish initializing

A fix for this is to put the makeFirstResponder: call in a block like so:

[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
        [[self window] makeFirstResponder: self];
}];

This puts off the makeFirstResponder: call until at least the next time
through the native run loop, so the window can finish initializing and
unblock the EDT before the AX system starts asking for information.

On 12/23/11 6:41 AM, Artem Ananiev wrote:
> Hi, team,
>
> as Pete doesn't have access to cr.openjdk.java.net yet and therefore
> can't put the webrev there, I have published the patch here:
>
> http://cr.openjdk.java.net/~art/macosx-port/mac_voiceover_hangs/
>
> Please, bear in mind I'm not the author of the fix, so address all the
> questions to Pete :)
>
> Thanks,
>
> Artem
>
> On 12/21/2011 7:58 PM, Pete Brunet wrote:
>> Hi Artem, Apparently the list manager stripped off my zip file.  Should
>> I upload it somewhere?  -Pete
>>
>> On 12/21/11 3:44 AM, Artem Ananiev wrote:
>>>
>>> Did you forget to attach the patch? :)
>>>
>>> Thanks,
>>>
>>> Artem
>>>
>>> On 12/20/2011 8:29 PM, Pete Brunet wrote:
>>>> The attached patch was created by Kevin Miller, reviewed by Mike
>>>> Swingler, and tested by me.
>>>>
>>>> This patch will fix the following bugs:
>>>> http://java.net/jira/browse/MACOSX_PORT-630
>>>> http://java.net/jira/browse/MACOSX_PORT-644
>>>> http://java.net/jira/browse/MACOSX_PORT-646
>>>>
>>>> It also includes a fix to a bug in an NSLog that I noticed when doing
>>>> some other debugging.
>>>>
>>>> Please review.
>>>>
>>>> Also, is there any information missing or something else I should have
>>>> done in the process of creating the patch?
>>>>
>>>> Pete


More information about the macosx-port-dev mailing list