Bug 460744 - [GTK] CTabFolder forces relayout on parent when tab is added
Summary: [GTK] CTabFolder forces relayout on parent when tab is added
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 4.5 M7   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks: 465644
  Show dependency tree
 
Reported: 2015-02-24 17:38 EST by Thomas Schindl CLA
Modified: 2015-04-28 17:09 EDT (History)
11 users (show)

See Also:


Attachments
Sample (1.69 KB, text/x-java-source)
2015-02-24 17:38 EST, Thomas Schindl CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schindl CLA 2015-02-24 17:38:52 EST
Created attachment 251076 [details]
Sample

Run the attached snippet and notice that adding an item to CTabFolder forces a relayout on ALL siblings of the CTabFolder which makes no sense at all.

The offending code for this is found in "org.eclipse.swt.custom.CTabFolder.runUpdate" which does a getParent().layout(true,true)!
Comment 1 Thomas Schindl CLA 2015-02-24 17:41:02 EST
This causes a whole lot of layout() calls when e.g. switching perspectives in eclipse and what's really bad is that layout(true,true) unconditionally layouts all and everything even not currently active tabs.

A bug report to talk about layouting stuff in CTabFolder currently not visible will follow shortly
Comment 2 Thomas Schindl CLA 2015-02-24 17:57:42 EST
See #460745 why this call makes this call even worse than it could be
Comment 3 Thomas Schindl CLA 2015-03-05 07:46:22 EST
i would at least have expected some feedback from SWT-Team - the later you look at it the less likely we can ship a fix for Mars
Comment 4 Lakshmi P Shanmugam CLA 2015-03-06 00:59:29 EST
Niraj, can you please investigate this?
Comment 5 Niraj Modi CLA 2015-03-11 04:42:05 EDT
Below fix made for GTK3, is forcing a relayout on Parent and all siblings:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=0757bcaef9d164ab26c143786c6ed075b2af44ce

Will investigate for a better fix @ GTK3, to avoid this re-layouting.
Comment 6 Niraj Modi CLA 2015-03-16 06:50:24 EDT
(In reply to Niraj Modi from comment #5)
> Below fix made for GTK3, is forcing a relayout on Parent and all siblings:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=0757bcaef9d164ab26c143786c6ed075b2af44ce

Note: Above fix was made as part of GTK3 bug 421127(https://bugs.eclipse.org/bugs/show_bug.cgi?id=421127#c55)
Comment 7 Thomas Schindl CLA 2015-03-16 06:54:12 EDT
At least one could constraint the layout only when running on Gtk3, so at least OS-X and win32 are not affected
Comment 8 Lars Vogel CLA 2015-03-16 06:56:38 EDT
(In reply to Thomas Schindl from comment #7)
> At least one could constraint the layout only when running on Gtk3, so at
> least OS-X and win32 are not affected

As Linux user, I would appreciate a fix for all platforms.
Comment 9 Thomas Schindl CLA 2015-03-16 07:01:35 EDT
right - this is just in case no Gtk3 fix is on available!
Comment 10 Andrey Loskutov CLA 2015-03-16 17:36:23 EDT
(In reply to Lars Vogel from comment #8)
> As Linux user, I would appreciate a fix for all platforms.

The original patch was a fix for *GTK3 only* bug, but the original patch introduced performance regression for ALL platforms.

(In reply to Niraj Modi from comment #5)
> Below fix made for GTK3, is forcing a relayout on Parent and all siblings:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=0757bcaef9d164ab26c143786c6ed075b2af44ce
> 
> Will investigate for a better fix @ GTK3, to avoid this re-layouting.

Are we talking about the fix for bug 421127 here?

In this case I would suggest to reopen bug 421127, and until the proper fix for bug 421127 is not available, fix the performance regression on ALL platforms but GTK3 by restricting the previous patch to *GTK3 only*.
Comment 11 Eclipse Genie CLA 2015-03-23 18:34:08 EDT
New Gerrit change created: https://git.eclipse.org/r/44413
Comment 12 Andrey Loskutov CLA 2015-03-23 18:37:29 EDT
(In reply to Eclipse Genie from comment #11)
> New Gerrit change created: https://git.eclipse.org/r/44413

I've tested on Fedora 21 (rpm -q gtk3 => gtk3-3.14.9-1.fc21.x86_64) and the original fix for bug 421127 comment 55 (commit 0757bcaef9d164ab26c143786c6ed075b2af44ce) is not needed to fix rendering issues in CustomControlExample.

getParent().layout(true, *false*) is enough to fix "empty" tabs in CTabFolder.
Comment 13 Alexander Kurtakov CLA 2015-03-26 09:41:40 EDT
(In reply to Andrey Loskutov from comment #12)
> (In reply to Eclipse Genie from comment #11)
> > New Gerrit change created: https://git.eclipse.org/r/44413
> 
> I've tested on Fedora 21 (rpm -q gtk3 => gtk3-3.14.9-1.fc21.x86_64) and the
> original fix for bug 421127 comment 55 (commit
> 0757bcaef9d164ab26c143786c6ed075b2af44ce) is not needed to fix rendering
> issues in CustomControlExample.
> 
> getParent().layout(true, *false*) is enough to fix "empty" tabs in
> CTabFolder.

Tested myself, no regression found with your patch. Will push shortly.
Comment 15 Alexander Kurtakov CLA 2015-03-26 09:43:16 EDT
In master now.
Comment 16 Lars Vogel CLA 2015-03-26 10:46:05 EDT
Would it be possible to measure the performance improvement with this patch? My performance measurement skills are very low, but I would be interested in learning how to do it and also to see the results for this enhancement.
Comment 17 Lars Vogel CLA 2015-03-27 08:36:06 EDT
In Build id: N20150326-2000 switching CSS styling does not work anymore, e.g., it does not update the CSS in the whole application. Can this be related to this change?
Comment 18 Andrey Loskutov CLA 2015-03-29 05:48:06 EDT
(In reply to Lars Vogel from comment #17)
> In Build id: N20150326-2000 switching CSS styling does not work anymore,
> e.g., it does not update the CSS in the whole application. Can this be
> related to this change?

I can't reproduce this, neither on GTK2 nor on GTK3, or I miss right steps to reproduce.

The original patch [1] which added getParent().layout(true, true); had nothing to do with CSS styling too.

[1] https://git.eclipse.org/r/#/c/25291/6/bundles/org.eclipse.swt/Eclipse+SWT+Custom+Widgets/common/org/eclipse/swt/custom/CTabFolder.java
Comment 19 Andrey Loskutov CLA 2015-03-30 16:53:27 EDT
(In reply to Lars Vogel from comment #17)
> In Build id: N20150326-2000 switching CSS styling does not work anymore,
> e.g., it does not update the CSS in the whole application. Can this be
> related to this change?

Lars, can you reproduce it? If not, please close this bug again, I don't think this change is related.
Comment 20 Lakshmi P Shanmugam CLA 2015-03-31 02:21:12 EDT
(In reply to Andrey Loskutov from comment #12)
> (In reply to Eclipse Genie from comment #11)
> > New Gerrit change created: https://git.eclipse.org/r/44413
> 
> I've tested on Fedora 21 (rpm -q gtk3 => gtk3-3.14.9-1.fc21.x86_64) and the
> original fix for bug 421127 comment 55 (commit
> 0757bcaef9d164ab26c143786c6ed075b2af44ce) is not needed to fix rendering
> issues in CustomControlExample.
> 
> getParent().layout(true, *false*) is enough to fix "empty" tabs in
> CTabFolder.

I think we should limit this fix only to GTK for 2 reasons:
- The code is unnecessary for Windows & Mac.
- It sends unexpected SWT.Resize events on its parent and siblings (for example when adding a new tab)

IMO, the real fix should be made in GTK code and this should be treated as a temporary fix/workaround.
Comment 21 Lars Vogel CLA 2015-03-31 04:23:29 EDT
(In reply to Andrey Loskutov from comment #19)
> (In reply to Lars Vogel from comment #17)
> > In Build id: N20150326-2000 switching CSS styling does not work anymore,
> > e.g., it does not update the CSS in the whole application. Can this be
> > related to this change?
> 
> Lars, can you reproduce it? If not, please close this bug again, I don't
> think this change is related.

I plan to test the reversion of change this week, sorry for the delay I have some pressing issues to work on and using a custom modified SWT is new to me.
Comment 22 Niraj Modi CLA 2015-03-31 07:20:42 EDT
(In reply to Lakshmi Shanmugam from comment #20)
> I think we should limit this fix only to GTK for 2 reasons:
> - The code is unnecessary for Windows & Mac.
> - It sends unexpected SWT.Resize events on its parent and siblings (for
> example when adding a new tab)
> 
> IMO, the real fix should be made in GTK code and this should be treated as a
> temporary fix/workaround.

Restricted the fix and effect to GTK only via below git patch:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ef9b2ace84f9bf3603ba33e4a4c8fc9ae7227032
Comment 23 Andrey Loskutov CLA 2015-03-31 17:37:10 EDT
(In reply to Niraj Modi from comment #22)
> (In reply to Lakshmi Shanmugam from comment #20)
> > I think we should limit this fix only to GTK for 2 reasons:
> > - The code is unnecessary for Windows & Mac.
> > - It sends unexpected SWT.Resize events on its parent and siblings (for
> > example when adding a new tab)
> > 
> > IMO, the real fix should be made in GTK code and this should be treated as a
> > temporary fix/workaround.
> 
> Restricted the fix and effect to GTK only via below git patch:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=ef9b2ace84f9bf3603ba33e4a4c8fc9ae7227032

Thanks.

I think this is only needed for GTK3. Does it make sense (and is it possible) to restrict the patch to this platform only? If not, should we close this bug?
Comment 24 Lars Vogel CLA 2015-04-01 03:58:35 EDT
(In reply to Lars Vogel from comment #17)
> In Build id: N20150326-2000 switching CSS styling does not work anymore,
> e.g., it does not update the CSS in the whole application. Can this be
> related to this change?


Looks like the fix for Bug 372517 causes the issues during theme switching. Sorry for the noise.
Comment 25 Niraj Modi CLA 2015-04-01 06:24:44 EDT
(In reply to Andrey Loskutov from comment #23)
> I think this is only needed for GTK3. Does it make sense (and is it
> possible) to restrict the patch to this platform only? If not, should we
> close this bug?
Since implementation of CTabFolder Control is common for all platforms, so we should-not(may be cannot) have GTK3 specific check in this code.

However, the 2nd concerns raised in comment 20 (now GTK only) is still open and should be addressed with a proper fix for GTK3.
Considering current fix as temporary, hence reopening this bug to continue discussion on this.
Comment 26 Andrey Loskutov CLA 2015-04-22 16:02:40 EDT
I'm not the SWT guru, so I fear I'm now not the right assignee for SWT GTK changes required according to comment 20 and comment 25.
Comment 27 Arun Thondapu CLA 2015-04-28 03:13:52 EDT
(In reply to Niraj Modi from comment #25)
> (In reply to Andrey Loskutov from comment #23)
> > I think this is only needed for GTK3. Does it make sense (and is it
> > possible) to restrict the patch to this platform only? If not, should we
> > close this bug?
> Since implementation of CTabFolder Control is common for all platforms, so
> we should-not(may be cannot) have GTK3 specific check in this code.
> 
> However, the 2nd concerns raised in comment 20 (now GTK only) is still open
> and should be addressed with a proper fix for GTK3.
> Considering current fix as temporary, hence reopening this bug to continue
> discussion on this.

Since the actual performance issue addressed by this particular bug has been fixed, I'll go ahead and resolve this one.

I'll clone and create a new bug to investigate if a GTK+ specific fix for the CTabFolder rendering issues can be found.
Comment 28 Andrey Loskutov CLA 2015-04-28 17:09:21 EDT
Verified in debugger in I20150428-0800 on GTK