After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 516680 - Critical warning when changing cursor in view with accessibility enabled
Critical warning when changing cursor in view with accessibility enabled
Status: RESOLVED FIXED
Product: GtkHtml
Classification: Other
Component: Editing
3.18.x
Other Linux
: Normal normal
: ---
Assigned To: Milan Crha
Evolution QA team
: 478705 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-02-15 15:05 UTC by Milan Crha
Modified: 2008-09-04 08:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed gtkhtml patch (2.96 KB, patch)
2008-02-15 18:37 UTC, Milan Crha
none Details | Review
proposed gtkhtml patch ][ (3.26 KB, patch)
2008-02-22 14:22 UTC, Milan Crha
none Details | Review
test patch (4.07 KB, text/plain)
2008-03-05 10:52 UTC, Milan Crha
  Details
Test app to check for focus event and FOCUSED state parity (354 bytes, text/plain)
2008-06-12 15:54 UTC, Willie Walker
  Details
proposed gtkhtml patch ]I[ (3.21 KB, patch)
2008-09-03 11:26 UTC, Milan Crha
committed Details | Review

Description Milan Crha 2008-02-15 15:05:58 UTC
Mathias Clasen told me that changing cursor position in text when writing mail in Evolution with accessibility enabled, will produce a critical warning on the console:
(evolution:13067): GLib-GObject-WARNING **: IA__g_object_weak_unref: couldn't find weak ref 0x2aaab3021310(0x3241f70)

I found I can reproduce it even with caret mode on.
Comment 1 Milan Crha 2008-02-15 17:43:35 UTC
It's actually against GtkHTML, in a11y/object.c is used "gail-focus-object". The change there steals old object to gail an it then claims in gtk/modules/other/gail/gail.c when calling g_object_weak_unref on the changed object data, not on the right one. I would like to suggest to not change that object data in GtkHTML at all, but I do not know if it's the proper fix, and for what it is there.
Comment 2 Milan Crha 2008-02-15 18:37:58 UTC
Created attachment 105347 [details] [review]
proposed gtkhtml patch

for gtkhtml;

I'm not sure if this is the right fix, but I believe it is. The call to
g_object_set_data (G_OBJECT(obj), "gail-focus-object", focus_object);
just steals object to gail, which expects to have there something with weak ref callback set. Because of later call to atk_focus_tracker_notify it just claims on missing thing. Also this call makes same thing as the g_object_set_data, but adds there a weak ref as a bonus. With this patch it seems like working, even I didn't have much idea how to test it properly.

Please notice also other changes I did there, I think they are right too.
Comment 3 Srinivasa Ragavan 2008-02-15 19:59:45 UTC
Milan, I absolutely have no idea on this code. CC'ing Li here.

Li can you help us review this Accesibility patch?
Comment 4 Li Yuan 2008-02-18 08:20:28 UTC
Sure, I will review the patch later.
Comment 5 Srinivasa Ragavan 2008-02-20 10:47:34 UTC
Thx Li. Try for 2.21.92 (Monday)
Comment 6 Li Yuan 2008-02-22 09:01:01 UTC
"gail-focus-object" is used by gail in gailwidget.c:gail_widget_ref_state_set, which determines whether add focus state to the object. AT can not find the focused object after applying the patch.
Comment 7 Milan Crha 2008-02-22 14:22:27 UTC
Created attachment 105762 [details] [review]
proposed gtkhtml patch ][

for gtkhtml;

Thanks for the review. I found other possibility how to solve this (I hope the 'solve' word is appropriate), it seems that it depends on the order of function calls, so I changed order to one which seems to be fine for both things.

Can you check/review this patch, please? Thanks in advance.
Comment 8 Li Yuan 2008-02-25 05:00:44 UTC
When calls atk_focus_tracker_notify, application will send out a "focus" event to accessibility infrastructure, and some AT (like Orca) will call back to ref_state_set. This will happen before 
g_object_set_data (G_OBJECT(obj), "gail-focus-object", a11y) after applying the patch. And AT will not get the focused state. So we need to call g_object_set_data before atk_focus_tracker_notify. Can we weak_ref the object before calling g_object_set_data?
Comment 9 Milan Crha 2008-02-25 14:05:58 UTC
We cannot, as far as I know. If we change the order, then we will be back where we were. The weak_ref is done in gtk/modules/other/gail/gail.c, in function gail_set_focus_object and is unreffed in this function too, and in gail_focus_tracker, which is called within the call of atk_focus_tracker_notify. It was the reason why I thought the remove of g_object_set_data from gtkhtml is correct, because it is playing with same thing twice.

Are you sure that the initial patch is not working properly with gail? Because when I was testing, then it was playing with proper (same) pointers, thus it should work.
Comment 10 Li Yuan 2008-02-26 06:51:27 UTC
(In reply to comment #9)
> Are you sure that the initial patch is not working properly with gail? Because
> when I was testing, then it was playing with proper (same) pointers, thus it
> should work.
> 

Do you test the with Orca running? The "focus" event I mentioned is used in accessibility infrastructure, not in GUI. So Orca may not find the focused object after applying the patch, depending on the logic in Orca.
Comment 11 Milan Crha 2008-02-26 08:18:40 UTC
Yeah, I tested with Orca running, I turned on the screen reader (I do not know the exact name, it shows text around the cursor), because I thought it's one of the usages of this, and I didn't notice any difference between before and after patch applied, the proper text around cursor has been shown up there.
Was it bad place to look at, or how can I test this properly?
Comment 12 Li Yuan 2008-02-26 08:31:41 UTC
Maybe Orca didn't call back synchronously. It still could be a problem in the future. We should set the focus object before we tell them the focus is changed, I think.
Comment 13 Willie Walker 2008-02-26 13:20:37 UTC
(In reply to comment #12)
> Maybe Orca didn't call back synchronously. It still could be a problem in the
> future. We should set the focus object before we tell them the focus is
> changed, I think.
> 

For performance reasons, Orca handles almost all events asynchronously.  As such, it might be likely that the objects reached the desired state by the time Orca actually processed the events.   You can force Orca to process events synchronously by adding the following line to the end of your ~/.orca/user-settings.py file:

orca.settings.asyncMode = False

However, in looking at this bug, my understanding is that a focus event is being generated for an object, but that object's FOCUSED state is not sent when the event is generated.  I believe the implementation should really strive to make sure the object state matches the event -- so, if the event is telling us the object now has focus, then the FOCUSED state should be set.
Comment 14 Milan Crha 2008-03-03 19:42:16 UTC
Can you point me how can I ensure it is working, say with Orca (which part of Orca?). If you can point me where to look, what exactly doesn't work with the first patch, then I can look at it and try to solve it properly, but without any idea where to look, it's more than hard (where I did look it seemed fine, so asking). Thanks.
Comment 15 Li Yuan 2008-03-04 04:04:23 UTC
From the code, we need to call
g_object_set_data (G_OBJECT(obj), "gail-focus-object", focus_object); before
atk_focus_tracker_notify (focus_object);
That means we need to tell gail the "obj" is the focused object first and then notify the focus change. Otherwise gail cannot find the focused object.

As Will said, you can set orca.settings.asyncMode = False in ~/.orca/user-settings.py, to see if Orca can still read the focused object.
Comment 16 Milan Crha 2008-03-05 10:52:45 UTC
Created attachment 106606 [details]
test patch

for gtkhtml (intentionally marked as plain text)

I did this test patch to see what it is doing based on object pointers, and it showed that the atk_focus_tracker_notify *do* set the "gail-focus-object" too, and the widget *has* set FOCUSED flag before calling atk_..._notify function. Based on this it seems that the first patch is correct. Or I obviously miss here something...

Here is my output on console after applying this test patch, with caret mode on, clicking with mouse to one paragraph in the preview panel, and then into  other paragraph:
gtk_html_a11y_grab_focus_cb:new_fo:0xcff6d0, my_fo:(nil), obj:0xcff720,
   gail_fo_before_notify:(nil): focus_set:1
        gail after atk_..._notify:0xcff6d0
        gail after set_data:0xcff6d0
gtk_html_a11y_grab_focus_cb:new_fo:0xf0fde0, my_fo:0xcff6d0, obj:0xcff720,
   gail_fo_before_notify:0xcff6d0: focus_set:1
        gail after atk_..._notify:0xf0fde0
        gail after set_data:0xf0fde0
Comment 17 Milan Crha 2008-03-05 11:14:21 UTC
OK, with asyncMode set to False it doesn't work. Is somewhere a UI option for this? I didn't find it in my user-settings, somehow, so Iwrote it there by hand.
Comment 18 Willie Walker 2008-03-05 12:32:36 UTC
(In reply to comment #17)
> OK, with asyncMode set to False it doesn't work. Is somewhere a UI option for
> this? I didn't find it in my user-settings, somehow, so Iwrote it there by
> hand.

This is a developer-only option, so Orca doesn't provide a UI option for it.

Comment 19 Milan Crha 2008-03-05 12:40:14 UTC
Thanks, good to know, so should I bother with sync mode? You know it definitely acts differently and I'm not sure if it does work "fine" in async for me only because of "quick" machine/good timing, or there can be any hidden issue which you see and I don't?
Comment 20 Willie Walker 2008-03-05 12:43:30 UTC
(In reply to comment #19)
> Thanks, good to know, so should I bother with sync mode? You know it definitely
> acts differently and I'm not sure if it does work "fine" in async for me only
> because of "quick" machine/good timing, or there can be any hidden issue which
> you see and I don't?
> 

The timing issue is one concern.  The other concern, however, is that we cannot expect all assistive technologies to behave like Orca.  True and proper behavior should exist when events are processed synchronously.  Thanks!
Comment 21 Milan Crha 2008-03-05 14:16:42 UTC
OK, I tried as you said, and surprisingly for me, it doesn't claim the unref warning in both cases. Anyway, it doesn't wand to read the text around cursor in both modes (sync versus async) for me,  I've probably something broken on my machine, I guess.

The problem is, when I disable accessibility feature in personal preferences and do not restart my machine, then I see the unref warning on the console. I know, it can be because I didn't logout, but should not this work properly anyway?
Comment 22 Li Yuan 2008-03-06 09:12:57 UTC
(In reply to comment #21)
> The problem is, when I disable accessibility feature in personal preferences
> and do not restart my machine, then I see the unref warning on the console. I
> know, it can be because I didn't logout, but should not this work properly
> anyway?
> 
If you start gnome-session with accessibility support enabled, no matter if you unset the accessibility gconf key ( System->Preferences->Universal access->Assistive Technology-->Enable assistive technologies) during runtime, atk-bridge and gail are loaded anyway (loaded by gtk_module_init, because gnome-session set GTK_MODULES to gail:atk-bridge). So I don't see any difference here...
Comment 23 Milan Crha 2008-03-06 09:25:14 UTC
I'm trying this on my updated Fedora 8 box. Do you think it does matter?
I see the difference between enabled/disabled from preferences without restart, when I've it enabled, then I see "tons" of other warnings about invalid type casts and similar things, but with disabled it disappears, except of unref warning.
Smells like NOTGNOME or I've really something broken here.
Comment 24 Li Yuan 2008-03-07 06:30:03 UTC
What is the version of GNOME on your system? Seems on your system gail and atk-bridge are not loaded if you unset the flag. I realize that Evolution calls gnome_program_init instead of gtk_init during startup, but on my system, gtk_module_init is called anyway (by gnome_program_init), so gail and atk-bridge is loaded. Maybe on your system gtk_module_init is not called. Anyway, I think you should set the flag and test the patch.
Comment 25 Milan Crha 2008-03-07 10:23:38 UTC
My Gnome is 2.20.3, but because I use Evolution 2.21.92 (the svn checkout) and it requires some newer packages, then I also compile my own glib/gtk/... and also atk, at-spi.

I will try on F9 and either close this or start to investigate more on fresh system. Thanks for your help.
Comment 26 Matthew Barnes 2008-03-11 01:05:54 UTC
Bumping version to a stable release.
Comment 27 Srinivasa Ragavan 2008-03-27 04:57:36 UTC
Milan, Any updates?
Comment 28 Milan Crha 2008-03-27 09:50:18 UTC
Nope, I'm sorry, still waiting for F9 to test it and see whether this was a problem on my local build only or is a generic problem. I will update/close this bug as soon as I will know more info.
Comment 29 Srinivasa Ragavan 2008-05-27 17:40:53 UTC
Mcrha: Any updates?
Comment 30 Milan Crha 2008-05-28 16:14:53 UTC
I can see the same warnings on my test machine with fresh new F9 with evo 2.22.1, thus we should (try to) fix it. The problem is I'm not able to produce any better patch than one of those I put here and I believe one of them is correct. Or if someone is thinking that's not truth, then please provide me steps how to reproduce it, like what to have turned on in a system, maybe installed too, and then how to see in evo what is wrong in described situation, because I do not see any difference with and without the patch (probably because I look into wrong place). Thanks in advance.
Comment 31 Willie Walker 2008-06-12 15:48:17 UTC
(In reply to comment #13)
> However, in looking at this bug, my understanding is that a focus event is
> being generated for an object, but that object's FOCUSED state is not sent when
> the event is generated.  I believe the implementation should really strive to
> make sure the object state matches the event -- so, if the event is telling us
> the object now has focus, then the FOCUSED state should be set.

I'll attach a test app to check for this case above.
Comment 32 Willie Walker 2008-06-12 15:54:55 UTC
Created attachment 112623 [details]
Test app to check for focus event and FOCUSED state parity
Comment 33 Srinivasa Ragavan 2008-06-13 03:45:15 UTC
Setting a different patch status to get it off my tracking list.
Comment 34 Milan Crha 2008-07-02 16:11:31 UTC
*** Bug 478705 has been marked as a duplicate of this bug. ***
Comment 35 Milan Crha 2008-09-03 11:26:35 UTC
Created attachment 117921 [details] [review]
proposed gtkhtml patch ]I[

for gtkhtml;

I had a chat with Li on #a11y and during some investigation I realized that touching "gail-focus-object" is unnecessary, it all does gail during call of atk_focus_tracker_notify, because when I try to get the object's data for this, then I get exactly the same object as we were trying to set before/after that. From that I believe to changing object's data directly is a violation of good behavior :)

Just for a record, the trace for the warning is this:
  • #0 IA__g_logv
    at gmessages.c line 395
  • #1 IA__g_log
    at gmessages.c line 517
  • #2 gail_set_focus_object
    at gail.c line 839
  • #3 atk_focus_tracker_notify
    from /usr/lib64/libatk-1.0.so.0
  • #4 gail_focus_idle_handler
    at gail.c line 585
  • #5 IA__g_main_context_dispatch
    at gmain.c line 2009
  • #6 g_main_context_iterate
    at gmain.c line 2642
  • #7 IA__g_main_loop_run
    at gmain.c line 2850
  • #8 gtk_main
    from /usr/lib64/libgtk-x11-2.0.so.0
  • #9 main
    at main.c line 410

From which you can see all the weak_reffing and weak_unreffing is done during call of atk_focus_tracker_notify in gail_set_focus_object, thus gail takes care of this itself, when it wants to.
Comment 36 Li Yuan 2008-09-04 02:50:38 UTC
Thanks for the patch.
Comment 37 Milan Crha 2008-09-04 08:50:34 UTC
Committed to trunk. Committed revision 8956.