Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 466314

Summary: [GTK3] Text in Forms abbreviated
Product: [Eclipse Project] Platform Reporter: Lars Vogel <Lars.Vogel>
Component: SWTAssignee: Alexander Kurtakov <akurtakov>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, arunkumar.thondapu, Lars.Vogel, malaperle, markdigitalchips, markus.kell.r, peter, snjezana.peco, sravankumarl
Version: 4.5   
Target Milestone: 4.6 M4   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/54397
https://git.eclipse.org/r/60884
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=eec69d54257dd905a06e43fb705f40df9326414e
https://bugs.eclipse.org/bugs/show_bug.cgi?id=494565
Whiteboard:
Bug Depends on:    
Bug Blocks: 441566, 474628    
Attachments:
Description Flags
Forms screenshot
none
Text widget snippet none

Description Lars Vogel CLA 2015-05-04 09:59:51 EDT
The text in forms looks cut of in Ubuntu 15.04 with uses GTK 3.15. I attach a screenshots a little bit later, once I have a decent Internet connection.

I did not notice this on Ubuntu 14.10.
Comment 1 Alexander Kurtakov CLA 2015-05-04 11:14:13 EDT
Does it really uses 3.15? 3.15.x are devel versions and should not be used in production. 3.16 is the stable release.
Comment 2 Lars Vogel CLA 2015-05-04 11:59:25 EDT
(In reply to Alexander Kurtakov from comment #1)
> Does it really uses 3.15? 3.15.x are devel versions and should not be used
> in production. 3.16 is the stable release.

Ups. I was quoting from memory, the real version seems to be 3.14

 libgtk-3-0:amd64    3.14.12-0ubuntu2 amd64 GTK+ graphical user interface library
ii  
libgtk-3-bin 3.14.12-0ubuntu2 amd64 rograms for the GTK+ graphical user interface library
libgtk-3-common 3.14.12-0ubuntu2 all common files for the GTK+ graphical user interface library
Comment 3 Lars Vogel CLA 2015-05-04 12:00:37 EDT
Created attachment 253142 [details]
Forms screenshot

Left is still the initial text, on the right side the result if I click on it.
Comment 4 Lars Vogel CLA 2015-07-23 00:51:21 EDT
Still the case for Eclipse Mars 4.5.
Comment 5 Sravan Kumar Lakkimsetti CLA 2015-08-18 05:53:36 EDT
*** Bug 468990 has been marked as a duplicate of this bug. ***
Comment 6 Sravan Kumar Lakkimsetti CLA 2015-08-18 05:56:59 EDT
This looks like problem with Text widget. On GTK3 the text draw starts one line above the widget boundary and 2 characters on the left side. This happens with Grid layout. 

Continuing with the investigations
Comment 7 Sravan Kumar Lakkimsetti CLA 2015-08-24 06:21:21 EDT
Here is the code snippet which is causing this problem

	OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, position, 0); //get the iterator at 0th location from the text buffer
	OS.gtk_text_buffer_place_cursor (bufferHandle, position); //place the cursor at the iterator
	long /*int*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle); //get the insert marker/location of cursor
	OS.gtk_text_view_scroll_mark_onscreen (handle, mark); //scroll the text view to show the marker - This is the problem in GTK3.14

this gtk_text_view_scroll_mark_onscreen is not working on GTK 3.14(works fine on GTK2). Can someone suggest what could be the problem?
Comment 8 Eclipse Genie CLA 2015-08-24 07:20:07 EDT
New Gerrit change created: https://git.eclipse.org/r/54397
Comment 9 Sravan Kumar Lakkimsetti CLA 2015-08-24 07:22:13 EDT
(In reply to Eclipse Genie from comment #8)
> New Gerrit change created: https://git.eclipse.org/r/54397

This change actually fixes this issue. But I am not sure this is the right thing to do.

I am looking for opinion on this from Marc-Andre and Alex
Comment 10 Marc-André Laperle CLA 2015-08-24 11:06:22 EDT
(In reply to Eclipse Genie from comment #8)
> New Gerrit change created: https://git.eclipse.org/r/54397

It it a question of the layout not allocating enough space for the Text widget? I'm asking that because it could be a problem with the computeSize being cached, a bit like bug 445801.
Comment 11 Sravan Kumar Lakkimsetti CLA 2015-08-25 02:48:14 EDT
(In reply to Marc-Andre Laperle from comment #10)
> (In reply to Eclipse Genie from comment #8)
> > New Gerrit change created: https://git.eclipse.org/r/54397
> 
> It it a question of the layout not allocating enough space for the Text
> widget? I'm asking that because it could be a problem with the computeSize
> being cached, a bit like bug 445801.

I do not think this is the problem with computeSize being cached. the call gtk_text_view_scroll_mark_onscreen is behaving erratically. 

for the offset of 0 the above call scrills to second line instead of first. and offset >0 it scrolls to last line.
Comment 12 Sravan Kumar Lakkimsetti CLA 2015-08-25 05:04:33 EDT
Retargetting to M2 since the change is risky
Comment 13 Marc-André Laperle CLA 2015-08-25 09:15:35 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #12)
> Retargetting to M2 since the change is risky

Did you mean 4.5.2 (or 4.6M2)? 4.5 M2 has passed.
Comment 14 Sravan Kumar Lakkimsetti CLA 2015-08-25 09:18:27 EDT
Oops I meant 4.6 M2
Comment 15 Marc-André Laperle CLA 2015-08-25 09:29:46 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #11)
> I do not think this is the problem with computeSize being cached. the call
> gtk_text_view_scroll_mark_onscreen is behaving erratically. 
> 
> for the offset of 0 the above call scrills to second line instead of first.
> and offset >0 it scrolls to last line.

Thanks! I think I'll look at the GTK code to see if it's a bug there and if there is a better workaround on the SWT side. To you have a snippet for this by any chance?
Comment 16 Sravan Kumar Lakkimsetti CLA 2015-08-27 04:01:53 EDT
Created attachment 256168 [details]
Text widget snippet

Please test this in GTK3 and GTK2. in GTK 3 when the widget is made visible the visible text is from the second line. in case of GTK 2 it is first line
Comment 17 Sravan Kumar Lakkimsetti CLA 2015-10-14 04:56:10 EDT
(In reply to Marc-Andre Laperle from comment #15)
> (In reply to Sravan Kumar Lakkimsetti from comment #11)
> > I do not think this is the problem with computeSize being cached. the call
> > gtk_text_view_scroll_mark_onscreen is behaving erratically. 
> > 
> > for the offset of 0 the above call scrills to second line instead of first.
> > and offset >0 it scrolls to last line.
> 
> Thanks! I think I'll look at the GTK code to see if it's a bug there and if
> there is a better workaround on the SWT side. To you have a snippet for this
> by any chance?

Hi Marc-Andre,

Did you had any luck with this bug? We are approaching M3. 

Thanks
Sravan
Comment 18 Marc-André Laperle CLA 2015-10-16 01:09:43 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #17)
> (In reply to Marc-Andre Laperle from comment #15)
> > (In reply to Sravan Kumar Lakkimsetti from comment #11)
> > > I do not think this is the problem with computeSize being cached. the call
> > > gtk_text_view_scroll_mark_onscreen is behaving erratically. 
> > > 
> > > for the offset of 0 the above call scrills to second line instead of first.
> > > and offset >0 it scrolls to last line.
> > 
> > Thanks! I think I'll look at the GTK code to see if it's a bug there and if
> > there is a better workaround on the SWT side. To you have a snippet for this
> > by any chance?
> 
> Hi Marc-Andre,
> 
> Did you had any luck with this bug? We are approaching M3. 

I just started to look at it. One thing about the snippet though, I get the same result with GTK 3.14.12 and GTK 3.10.8 so I'm not sure it's representative of the bug since I only see the bug in the workbench (like the attached screenshot) with GTK 3.14.12.
Comment 19 Marc-André Laperle CLA 2015-10-17 00:11:10 EDT
I have bisected the GTK repo and found the first "bad" commit. It sounds quite interesting:

commit 9d7f1caca7073cdf4af3bd85b24dbe0209abdde2
Author: Carlos Garnacho <carlosg@gnome.org>
Date:   Mon Jul 21 21:16:32 2014 +0200

    textview: Avoid relocating adjustments on ::size-allocate while these are animating
    
    An animation may be scheduled while the textview content changed in size, so the resize
    queued would just unset the animation and set the adjusments with a current value,
    defeating gtk_text_view_scroll_to_iter(). In this case, just avoid the adjustment change,
    as there is a target value on the way.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733406

It looks like animation was added by this commit:
https://git.gnome.org/browse/gtk+/commit/?id=6aa851149598961f7e80d204d92f1b4c74783b87

then for a few commits it still "worked" in Eclipse because of https://bugzilla.gnome.org/show_bug.cgi?id=733406, until 9d7f1caca70 was applied a few days later. I'll have to look into this a bit more to understand.
Comment 20 Sravan Kumar Lakkimsetti CLA 2015-10-21 05:32:40 EDT
Retargetting to M4 as it requires understanding of GTK code as well
Comment 21 Eclipse Genie CLA 2015-11-20 06:25:36 EST
New Gerrit change created: https://git.eclipse.org/r/60884
Comment 22 Alexander Kurtakov CLA 2015-11-20 06:27:39 EST
Marc-Andre, Sravan, please test my patch/approach. I'm quite confident this approach would be best for us due to the minimal change while still achieving the wanted behavior. Furthermore it gives us some more detailed control if tweaking needed in the future.
Comment 24 Alexander Kurtakov CLA 2015-11-24 02:08:12 EST
Marking as fixed now.
Comment 25 Marc-André Laperle CLA 2016-02-05 02:02:06 EST
Could this be ported to 4.5.2? I just noticed it while testing 4.5.2RC2.
Comment 26 Sravan Kumar Lakkimsetti CLA 2016-02-05 05:23:08 EST
(In reply to Marc-Andre Laperle from comment #25)
> Could this be ported to 4.5.2? I just noticed it while testing 4.5.2RC2.

It actually too late. We don't have anymore scheduled builds. If there is RC4 scheduled for any other reason we will consider this subject to PMC approval.
Comment 27 Markus Keller CLA 2016-05-25 12:07:41 EDT
This change most probably broke automatic scrolling in all touched methods, see bug 494565 comment 2.