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 118264 - Pan's autowrap code too slow & conflicts w/gtkspell
Pan's autowrap code too slow & conflicts w/gtkspell
Status: RESOLVED OBSOLETE
Product: Pan
Classification: Other
Component: general
pre-0.14.1 betas
Other Linux
: Normal major
: 1.0
Assigned To: Charles Kerr
Pan QA Team
: 121700 127739 147976 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-07-25 06:34 UTC by Jan De Luyck
Modified: 2006-10-06 21:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDB Trace (10.43 KB, text/plain)
2003-07-28 10:25 UTC, Jan De Luyck
Details
backtrace using paste (6.17 KB, text/plain)
2003-08-06 19:22 UTC, Christophe Lambin
Details
same error, different backtrace (3.78 KB, text/plain)
2003-08-06 20:35 UTC, Charles Kerr
Details
gprof output (42.07 KB, application/octet-stream)
2003-08-07 07:31 UTC, Jan De Luyck
Details
Gprof output, attempt 2 ;p (60.11 KB, application/octet-stream)
2003-08-07 08:16 UTC, Jan De Luyck
Details

Description Jan De Luyck 2003-07-25 06:34:44 UTC
Using CVS extract of today, July 25

When I posted something I noticed that for every character I enter it uses 
up a lot of CPU time causing the entry to slow.

It also causes a bunch of messages saying:

'You can apply tags and insert marks without invalidating your interators,' 
where the comma seems to suggest that more text is to follow, but I don't 
see any more.
Comment 1 Jan De Luyck 2003-07-25 06:37:07 UTC
Just saw the 'save log' feature ;pp

Fri, 25 Jul 2003 07:56:23 - Gtk - Invalid text buffer iterator: either 
the iterator is uninitialized, or the characters/pixbufs/widgets in 
the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a 
position across buffer modifications.
You can apply tags and insert marks without invalidating your 
iterators,
but any mutation that affects 'indexable' buffer contents (contents 
that can be referred to by character offset)
will invalidate all outstanding iterators
Fri, 25 Jul 2003 07:56:23 - Gtk - file gtktextbuffer.c: line 3616 
(_gtk_text_buffer_get_line_log_attrs): assertion `GTK_IS_TEXT_BUFFER 
(buffer)' failed
Comment 2 Jan De Luyck 2003-07-25 06:37:45 UTC
Forgot this one :-(

Fri, 25 Jul 2003 07:56:23 - Gtk - file gtktextbuffer.c: line 3616 
(_gtk_text_buffer_get_line_log_attrs): assertion `GTK_IS_TEXT_BUFFER 
(buffer)' failed

Comment 3 Charles Kerr 2003-07-25 15:26:05 UTC
I'm not getting the CPU lag, nor the errors.
Hmm.  What version of gtk+ are you running?

Also helpful: start pan inside of gdb, and set a breakpoint
for log_error_breakpoint, then try typing in the compose window
so that you can get backtraces for these error messages:

% gdb pan
(gdb) break log_error_breakpoint
Breakpoint 1 at 0x808a55e: file pan.c, line 145.
(gdb) r
Starting program: /home/charles/src/pan/pan/pan
[New Thread 16384 (LWP 4269)]
[New Thread 32769 (LWP 4270)]
[New Thread 16386 (LWP 4271)]
[New Thread 32771 (LWP 4272)]
[New Thread 49156 (LWP 4273)]
[New Thread 65541 (LWP 4274)]
[New Thread 81926 (LWP 4275)]
[New Thread 98311 (LWP 4276)]
[Switching to Thread 16384 (LWP 4269)]

[try composing an article until you reach the breakpoint]

Breakpoint 1, log_error_breakpoint () at pan.c:145
145     }
(gdb) thread apply all bt 

[and attach the output of that to this bug report]
Comment 4 Jan De Luyck 2003-07-28 06:13:30 UTC
[cvs today]

gtk: libgtk-2.2.2

The slowdown is still present, but the errors in the log seem to 
appear only when pressing 'post'.

What's even more weird: after I tried running it through gdb I can't 
seem to get that error anymore. Am I going delerious? ;p
Comment 5 Jan De Luyck 2003-07-28 10:24:54 UTC
OK! I managed to trigger it again (needed to type a lot of text before 
it triggers)

Appending gdb trace
Comment 6 Jan De Luyck 2003-07-28 10:25:19 UTC
Created attachment 18673 [details]
GDB Trace
Comment 7 Charles Kerr 2003-07-29 04:30:29 UTC
aaaahh...  looks like I need to dust off a spellchecked copy of Pan. :)
Comment 8 Charles Kerr 2003-07-30 21:59:31 UTC
This is consistently reproducable with gtkspell turned on.
Comment 10 Jan De Luyck 2003-08-05 10:54:27 UTC
Only one part of this bug is fixed: the high cpu usage is still 
present!
Comment 11 Charles Kerr 2003-08-05 15:20:59 UTC
-N  - 10208/10237: Bobby D. Bryant

> Something's really wrong with the composition window.
> When typing in a reply my CPU usage will jump to over
> 50% after a few keystrokes, and not drop back until a
> couple of seconds after I quit typing.
                                                                     
                                                        > 
> Things were formerly kind of slow if you typed in the
> middle of a paragraph and forced re-wrap calculations
> with every keystroke, but what I'm seeing with '94 happens
> even if you start typing on a blank line.
Comment 12 Charles Kerr 2003-08-05 18:35:49 UTC
I can't reproduce this -- when I'm typing, even with spellcheck turned
on, my PC barely shows a blip on the CPU monitor (and my PC is no
speed demon).  So there is most likely something different between my
configuration and yours.

Jan & Bobby: what version of gtk+ are you using?
Comment 13 Bobby D. Bryant 2003-08-05 20:09:27 UTC
I am currently using GTK+ 2.2.2.  However, this problem only happened
when I tried Pan 0.14.0.94; when I failed back to 0.14.0 the problem
went away, even building with the same version of GTK+.  Tentative
conclusion: if it's a bug in GTK+, it must be in something 0.14.0.94
is using that 0.14.0 isn't.

FWIW, I do use spellchecking, and my Pan builds are based on gtkspell
2.2.2.  My pango is 1.2.1.  Holler if anything else may be relevant.

Thanks.
Comment 14 Charles Kerr 2003-08-05 20:57:49 UTC
Just out of curiosity, could you try upgrading to pango 1.2.2?
Comment 15 Charles Kerr 2003-08-05 20:58:49 UTC
(yes, I'm grasping at straws. ;)
Comment 16 Bobby D. Bryant 2003-08-06 04:36:23 UTC
> Just out of curiosity, could you try upgrading to pango 1.2.2?

I just tried that, but it broke Pan and several other applications so
I had to fail back to 1.2.1.  Don't know what the problem is.
Comment 17 Jan De Luyck 2003-08-06 09:31:25 UTC
Using Debian Unstable,

gtk2 2.2.2
pango1 1.2.3
gtkspell  2.0.4
Comment 18 Christophe Lambin 2003-08-06 18:51:28 UTC
On my system, typing normal text drives my CPU to about 35% (800MHz),
with none of the mentioned error messages.

The only way I can reproduce this, is to type a big block of text,
copy it and then paste it *at the end of the line*, i.e. not on a new
line, but at the end of the previous line.  This pegs the CPU at 100%
for a while and produces a burst of the mentioned error messages.

GProf has the following to say:

Flat profile:
 
Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls  us/call  us/call  name
 40.00      0.02     0.02    10100     1.98     1.98  wrap_line_at_column
 20.00      0.03     0.01     9256     1.08     1.08 
text_massager_get_wrap_column
 20.00      0.04     0.01                             mark_set_cb
 10.00      0.04     0.01                             text_was_inserted_cb
 10.00      0.05     0.01                             wrap_tb_toggled_cb

If helpful, I can see if I can build a gprof-enabled version of gtkspell.
Comment 19 Christophe Lambin 2003-08-06 19:22:13 UTC
Created attachment 18969 [details]
backtrace using paste
Comment 22 Christophe Lambin 2003-08-06 20:16:34 UTC
Changes to text-massager.c were already in.  The changes to
message-window.c help somewhat, according to gprof.  The gtk errors on
paste, along with the 100% CPU spike remain.
Comment 23 Charles Kerr 2003-08-06 20:35:05 UTC
Created attachment 18972 [details]
same error, different backtrace
Comment 24 Charles Kerr 2003-08-06 21:04:54 UTC
Fixed the error messages:

http://cvs.gnome.org/bonsai/cvsview2.cgi?diff_mode=context&whitespace_mode=show&subdir=pan/pan&command=DIFF_FRAMESET&file=message-window.c&rev1=1.379&rev2=1.380&root=/cvs/gnome

When we changed the text buffer due to wrap, we invalidated the
insert_pos iterator passed into text_was_inserted_cb().  Under certain
circumstances, that iterator is actually used again, so we need to
revalidate it before text_was_inserted_cb() returns.

Chris, please do another CPU test with a fresh CVS build that has
the above change.  If the CPU usage is reasonable, this issue should
be marked as fixed.
Comment 25 Christophe Lambin 2003-08-06 21:29:04 UTC
Error messages are gone, as are the CPU spikes. Pasting a big block in
spell-mode is now near-instantaneous (same as no-spell mode).

Marking as fixed (nice work, again).
Comment 26 Jan De Luyck 2003-08-07 06:02:27 UTC
I've just double-checked my cvs source vs the bonsai-visible changes 
to make sure I'd gotten all the changes...

Unfortunately the problem is still present... 

If I press any key in the composing window, the system will spike to 
100%, and it is very sluggish. The same effect one would get if you 
would run Wordperfect 6 on a 286 box ;pp

Could you give me some pointers (a howto? ;p) on how to build a gprof 
enabled pan copy?
Comment 27 Christophe Lambin 2003-08-07 06:44:37 UTC
Well, that's nice, isn't it? :)

Just to rule out any CVS sync lag, this is the ChangeLog entry you're
looking for:

        * pan/message-window.c (text_was_inserted_cb): remember that
        if we change the text that was inserted, that we need to
        revalidate the GtkTextIterator passed into us by the signal's
        source.
        (118264, Bobby D. Bryant)

Can you verify that the error messages are now gone?

To build a gprof-enabled version of pan:
        $ CFLAGS="-Wall -ggdb3 -pg"
        $ ./autogen.sh
        $ make clean all

Running pan then produces a file gmon.out, which you run through gprof:
        $ gprof pan gmon.out
Comment 28 Jan De Luyck 2003-08-07 06:58:15 UTC
What can I say ;p

Anyway, the entry is present in the ChangeLog, doing a profile build 
now.
Comment 29 Jan De Luyck 2003-08-07 07:31:25 UTC
Created attachment 18991 [details]
gprof output
Comment 30 Christophe Lambin 2003-08-07 07:59:38 UTC
This output spent more time indexing your cache than it did wrapping
text. :) 

For a gprof output to make any sense, you need to hit the rewrap code
as much as possible. In short, type more. :)
Comment 31 Jan De Luyck 2003-08-07 08:16:06 UTC
Created attachment 18992 [details]
Gprof output, attempt 2 ;p
Comment 32 Jan De Luyck 2003-08-07 08:17:20 UTC
(i don't know Pan well enough to say this, so hit me if I'm saying 
something stupid)

It seems to me that it doesn't really happen to be the wrapping code.

if i post a new message, only the sig is present. if i start typing 
then, the effect is already visible - even with only 1 character.
Comment 33 Bobby D. Bryant 2003-08-07 12:12:28 UTC
That was my experience as well.  I was replying to an existing
message, but typing into a blank line below the quoted text.  The CPU
spike occurred regardless of where I was on the line.
Comment 34 Charles Kerr 2003-08-07 15:22:10 UTC
Jan, Bobby: what happens if you run without spellcheck?
Comment 35 Charles Kerr 2003-08-07 19:12:16 UTC
Jan, Bobby:  I was thinking about what differences between your setups
and mine and Chris' that could cause the problem.  To help narrow down
the possible sources of problems.

Try doing these one by one and see which one (if any) helps.

(1) Run without spellcheck.
(2) Turn off your signature file.
(3) Post a completely new message so there's no quoted text.

Even if things are still slow w/o spellcheck, w/o a signature file,
and w/o quoted text, we've still narrowed down the possible causes of
the problem.
Comment 36 Jan De Luyck 2003-08-08 09:45:07 UTC
I'm currently rebuilding pan without spellchecking. I've tried a few 
things with spellchecking enabled (from today's CVS ofcourse ;p).

I'm always trying to post new messages, and with or without signature 
doesn't really make a difference.

When the build has completed I'll test without spellchecking.
Comment 37 Jan De Luyck 2003-08-08 10:03:19 UTC
Without spellchecking, without signature file, still cpu spikes and 
the 'laggyness'
Comment 38 Charles Kerr 2003-08-15 17:22:58 UTC
<shrug>  Maybe the stable release of 0.14.1 will shake out some new
testers and insights on this.  I've got no idea why you're seeing the
behavior that yoou're seeing.
Comment 39 Charles Kerr 2003-08-29 22:42:42 UTC
Mass-bumping of 0.14.2 features to 0.14.3 to make way for an emergency 0.14.2
release.
Comment 40 Christophe Lambin 2003-09-07 20:55:27 UTC
*** Bug 121700 has been marked as a duplicate of this bug. ***
Comment 41 John Thacker 2004-01-23 08:23:02 UTC
I get this same bug, (with both 0.14.2 and 0.14.2.90) only it's even
more annoying than noted here; it actually causes text loss.  It
happens in both gtkspell-enabled and disabled versions, so long as
"wrap text" is turned on.

Steps to reproduce:

1) Followup to a news post.
2) Make sure "wrap text" is selected as on.
3) Start adding text to the middle of a line, say a line of quoted text.
4) When the current line hits the 80 column limit and should re-wrap,
instead everything in the current paragraph to the right of the cursor
is magically deleted.  The error message:

"Gtk - Invalid text buffer iterator: either the iterator is
uninitialized, or the characters/pixbufs/widgets in the buffer have
been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a
position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents
that can be referred to by character offset)
will invalidate all outstanding iterators
Gtk - file gtktextbuffer.c: line 1697 (gtk_text_buffer_set_mark):
assertion `gtk_text_iter_get_buffer (iter) == buffer' failed "

Very, very frustrating, as this results in lost text unless "wrap
text" is deselected each time.
Comment 42 John Thacker 2004-02-09 20:16:52 UTC
So, I noticed that the version of the above problem I mention only
happens when using a GTK input method, specifically im-ja.

im-ja.sourceforge.net

It doesn't happen with XIM; I assume there's some sort of conflict
between the word wrap and the input method, but I don't know where the
blame lies.
Comment 43 Christophe Lambin 2004-05-02 19:43:38 UTC
*** Bug 127739 has been marked as a duplicate of this bug. ***
Comment 44 Christophe Lambin 2004-11-22 21:54:37 UTC
*** Bug 147976 has been marked as a duplicate of this bug. ***
Comment 45 Jan De Luyck 2005-08-25 08:05:43 UTC
Today I removed my custom gtk-2.0 theme and switched to a gtk2-qt based 
rendering theme, and this problem is _gone_. When I switch back, it's there 
again. So it seems somehow intermixed with that?

Or is it a problem with the text box used (different widget now drawn by QT)?

Weird.
Comment 46 Charles Kerr 2006-05-16 05:57:18 UTC
It's been literally years since I've seen this problem.  Some of the
rewrap code was ported over to the C++ rewrite, so I'm hesitant to
mark this as `obsolete' yet.

I'll hedge my bets and mark this as `needinfo'.  If anyone is still
getting these problems in the new versions of Pan, please change it
to reopened and let me know.

Also, running Pan and sysprof at the same time so that you can profile
where Pan's running away with the CPU would be _great_.
Comment 47 Christophe Lambin 2006-08-05 09:38:19 UTC
Updating target release.
Comment 48 André Klapper 2006-10-06 18:06:56 UTC
Closing this bug report as no further information has been provided. Please feel free to reopen this bug if you can provide the information Charles asked for in comment 46. Thanks in advance!
Comment 49 Jan De Luyck 2006-10-06 18:36:10 UTC
Sorry, forgot to add a while back, that I can't trigger this bug in the C++ rewrite, no matter what I do. So yes, closing it is ideal :)

Jan