Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 267468 - [SWT_AWT] Browser.print(GC) flickers
Summary: [SWT_AWT] Browser.print(GC) flickers
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-06 18:47 EST by Christopher Deckers CLA
Modified: 2009-04-30 21:43 EDT (History)
3 users (show)

See Also:


Attachments
Browser flickering in action (2.76 KB, text/x-java)
2009-03-06 18:47 EST, Christopher Deckers CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Deckers CLA 2009-03-06 18:47:27 EST
Created attachment 127887 [details]
Browser flickering in action

Build ID: SWT-N20090305-2000

Steps To Reproduce:
1. Embed the browser in a Canvas.
2. Launch the application with sun.awt.noerasebackground set to true.
3. Print the control now and then: it flickers.


More information:
It seems that Control.printWidget(in, int, GC), line 2067 causes the flickering:
SetWindowPos (hwnd, hwndInsertAfter, rect1.left, ...

If I replace it with this line, the flickering goes away:
setRedraw(false);
SetWindowPos (hwnd, hwndInsertAfter, rect1.left, ...
setRedraw(true);
Comment 1 Silenio Quarti CLA 2009-03-16 11:06:25 EDT
I cannot reproduce this problem. Which JDK are you running?
Comment 2 Steve Northover CLA 2009-03-16 11:18:05 EDT
I can't see it either.  We must be running a different version of something.  What XP theme are you using?
Comment 3 Christopher Deckers CLA 2009-03-16 14:14:57 EDT
I tried with 1.6.0_10, 1.5.0_12 and 1.6.0_14, and they all have the same flickering issue.
I use Windows XP default Luna blue theme, but I switched to Windows classic theme with 1.6.0_10 and got the same issue.

I have Windows XP Service Pack 3 on a 2GHz dual-core laptop, 2GB RAM. Graphic card is NVidia GeForce Go 7400.

When I run the sample I gave you, it does not blink for every print(gc) call but I would say 30-50% of the time, which is quite noticable. Moreover, the caret does not need to be in the search field for this to happen (so caret blinking is not the culprit for the Shell to flicker).

Before the "printing hack" was put in place, I had my own hack and I noticed that some of the calls made the window to flicker. I wrapped some of the calls with setRedraw(false/true) which allowed to remove those flickering. The same technique works with your hack as indicated in the bug description.

If you need more information, please let me know.
Comment 4 Steve Northover CLA 2009-03-16 14:29:01 EDT
I can't see putting in the setRedraw() true/false without seeing it do something.  Using setRedraw() should guarantee one complete redraw when the setRedraw(true) is executed.
Comment 5 Christopher Deckers CLA 2009-03-16 14:39:17 EDT
> I can't see putting in the setRedraw() true/false without seeing it do
> something.

I wonder how we can resolve this one. I hope you manage to reproduce it on some of you systems, or else you are welcome over here in France :)

>  Using setRedraw() should guarantee one complete redraw when the
> setRedraw(true) is executed.

Adding a redraw() call at the end of the "if(fixPrintWindow)" (in addition to the setRedraw(false/true)) does not make anything to flicker and probably guarantees that it is properly redrawn.

Maybe if one knows a video capturing program, I could show you the flickering in action (provided it captures with a high enough frame rate I guess).

Comment 6 Christopher Deckers CLA 2009-03-16 15:25:53 EDT
Maybe this is a matter of system speed. If it is, then we can slow it down.

Simply add these lines after "SetWindowPos (hwnd, hwndInsertAfter, rect1.left...":

try {
  Thread.sleep(100);
} catch(Exception e) {}

On my system, this makes the whole shell white. This is exactly the effect I get when I say it flickers, but for a longer time of course.
If I add the setRedraw(false/true) calls around the setWindowPos and sleep calls, then I don't see anything unusual.

-Christopher
Comment 7 Silenio Quarti CLA 2009-03-20 15:28:43 EDT
When I run the snippet fixPrintWindow=false, so that code does not run.
Comment 8 Silenio Quarti CLA 2009-03-20 15:33:39 EDT
If I make the code run it flickers.
Comment 9 Christopher Deckers CLA 2009-03-20 15:39:50 EDT
Yes, the snippet was created before several improvements (223590, 267466).
When we hit a condition where fixPrintWindow is true (region clip), then it does flicker.
Comment 10 Silenio Quarti CLA 2009-03-20 16:51:01 EDT
Fixed > 20090320
Comment 11 Steve Northover CLA 2009-03-20 17:54:19 EDT
Christopher, *please* make sure the code we have in the bug report is showing the problem, otherwise, it's a waste of time and your bug won't get fixed (unless we can guess at it).
Comment 12 Christopher Deckers CLA 2009-03-20 18:23:14 EDT
> Christopher, *please* make sure the code we have in the bug report is showing
> the problem

My apologies, I should have checked that after your recent GC-related fixes, and adjust the code (adding a region clip in this case).

Again, thanks all for your great work!