Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) - SOLVED((kCGErrorCannotComplete: CGSDeviceSynchronize: Invalid device window))
Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) - SOLVED [message #490795] Sat, 10 October 2009 21:23 Go to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Hi, everybody,


I've encountered a strange problem with Mac OS X 10.6 and SWT 3.5. When my SWT application recreates a Composite with its children, I get the following error in the console window:

Mac-Pro.local java[382] <Error>: kCGErrorCannotComplete: CGSDeviceSynchronize: Invalid device window

This error is printed out many times per second while the application seems to be running on fine without any problems.

I have never experienced these problems before upgrading to Mac OS X 10.6 and the code of my application hasn't changed since the upgrade. This is clearly not a SWT issue, so I don't have a clue how to address it.

Is it possible that Apple JVM has issues with the new Snow Leopard?

Any help, hint or idea regarding this error would be greatly appreciated.


Best regards,

Albert

[Updated on: Wed, 21 October 2009 08:02]

Report message to a moderator

Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #491134 is a reply to message #490795] Tue, 13 October 2009 12:40 Go to previous messageGo to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
It seems that this is really some exotic kind of error, since I haven't found anything informative on the Internet regarding this problem.

Even googleing for just "CGSDeviceSynchronize: Invalid device window" returns only about 10 hits.

But I can confirm now that this error doesn't occur on Leopard 10.5.6, while I managed to reproduce it without problems on two other Macs running Snow Leopard.

I'm not very experienced Mac user myself, so I really don't have an idea what is going on here.


Best regards,

Albert

[Updated on: Tue, 13 October 2009 12:40]

Report message to a moderator

Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #491215 is a reply to message #491134] Tue, 13 October 2009 16:19 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi, some questions which could be helpful:

- are you able to provide some way of reproducing the problem (eg.- a
snippet like http://www.eclipse.org/swt/faq.php#whatisasnippet , a reduced
version of your app, etc.)?
- do you use any less-typical parts of swt in your app (eg.- SWT_AWT bridge,
etc.)?
- does swt's Carbon implementation behave any differently? (note:
http://www.eclipse.org/swt/faq.php#cocoa32launch )

Grant


"Albert" <albert.pikus@gmail.com> wrote in message
news:hb1sf2$154$1@build.eclipse.org...
> It seems that this is really some exotic kind of error, since I haven't
found anything informative on the Internet regarding this problem.
>
> Even googleing for just "CGSDeviceSynchronize: Invalid device window"
returns only about 10 hits.
>
> But I can confirm now that this error doesn't occur on Leopard 10.5.6,
while I managed to reproduce it without problems on two other Macs running
Snow Leopard.
>
> I'm not very experienced Mac user myself, so I really don't have an idea
what is going on here.
>
Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #491340 is a reply to message #491215] Wed, 14 October 2009 08:28 Go to previous messageGo to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Hi, Grant,

thank you for your reply!

I'm afraid I cannot provide a snippet, because the critical part of code is too complex to be just "pulled out" of my application. But basically, my application opens another shell, which is being updated from the UI thread and closed afterwards. Then a composite inside my main shell is recreated and this is the point when the above mentioned error gets printed in the Console. I have also built a jar file and run it from Terminal application, which gives the exactly same result.

No, I'm using pure SWT and not using SWT_AWT bridge, not using JFace etc.

I tried to run my application in 32-bit mode too, using 32-bit cocoa SWT library, but result is the same. On the other hand, I have no such problems on Mac OS 10.5.x. The application also runs fine on Linux and on Windows.

I also forgot to include the second line of this "stack trace" in my first post, which is:

Wed Oct 14 10:07:21 Mac-Pro.local java[1423] <Error>: kCGErrorCannotComplete: CGSDeviceSynchronize: Invalid device window

Second line:
Wed Oct 14 10:07:21 Mac-Pro.local java[1423] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.

Wed Oct 14 10:07:21 Mac-Pro.local java[1423] <Error>: kCGErrorCannotComplete: CGSDeviceSynchronize: Invalid device window

After this, the last error is, as said, repeated ad infinitum, while the application is still running as expected.

Even if this printing of error doesn't affect the performance of application, it's still very annoying.


Thanks again for your help, have a nice day,

Albert

[Updated on: Wed, 14 October 2009 08:29]

Report message to a moderator

Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #492028 is a reply to message #490795] Sat, 17 October 2009 09:11 Go to previous messageGo to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Hi, Grant,

I have discovered what is causing this error to be printed into console. I also have a simple "about shell" in my application, where I'm using GC in order to measure the width of some label on this shell, like this:

GC gc = new GC(infoLabel);
Point pt = gc.textExtent(infoLabel.getText());

When about shell is created and when I close it afterwards, this error gets printed like crazy. If I don't use GC, everything is fine and no error is printed.

I will provide a simple snippet, when I'll find some time, but basically it's very simple to reproduce this, as mentioned above.

I would like to emphasize though that this error applies only to Snow Leopard - on Leopard there is no such behavior.


Thank you for your time, regards,

Albert
Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #492033 is a reply to message #490795] Sat, 17 October 2009 10:01 Go to previous messageGo to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
I have also discovered that I can avoid this error to appear if I call dispose() on GC when I'm finished with laying out a label (I'm using FormLayout), like this:

GC gc = new GC(infoLabel);
Point pt = gc.textExtent(infoLabel.getText());      
            
formData.left = new FormAttachment(infoLabel, left, SWT.LEFT);
formData.right = new FormAttachment(infoLabel, pt.x, SWT.LEFT);
            
infoLabel.setLayoutData(formData);

// Explicitly call dispose            
gc.dispose();


Normally this isn't required, since all the shell's children should be disposed automatically when shell is disposed.

This is strange behavior indeed.


Have a nice day,

Albert
Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #492148 is a reply to message #492033] Mon, 19 October 2009 07:15 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
Albert wrote:
> I have also discovered that I can avoid this error to appear if I call
> dispose() on GC when I'm finished with laying out a label (I'm using
> FormLayout), like this:
>
>
> GC gc = new GC(infoLabel);
> Point pt = gc.textExtent(infoLabel.getText());
> formData.left = new FormAttachment(infoLabel, left, SWT.LEFT);
> formData.right = new FormAttachment(infoLabel, pt.x, SWT.LEFT);
> infoLabel.setLayoutData(formData);
>
> // Explicitly call dispose gc.dispose();
>
>
> Normally this isn't required, since all the shell's children should be
> disposed automatically when shell is disposed.
>
> This is strange behavior indeed.

No, it is not: You always need to dispose a new'ed GC:

"Application code must explicitly invoke the GC.dispose() method to
release the operating system resources managed by each instance when
those instances are no longer required."

You are using the constructor

public GC(Drawable drawable)

which has the explicit requirement

"You must dispose the graphics context when it is no longer required."

This seems a very strict requirement to me.

Eclipse has a very clear allocation policy here. For the same reason
you are not supposed to dispose any GC that you obtain as argument
of a specific event, like a PaintEvent event.

Greetings from Bremen,

- Daniel
Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #492521 is a reply to message #492148] Tue, 20 October 2009 15:55 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
I've logged https://bugs.eclipse.org/bugs/show_bug.cgi?id=292780 .

"Daniel Kr
Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #492631 is a reply to message #492148] Wed, 21 October 2009 07:59 Go to previous messageGo to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Quote:

No, it is not: You always need to dispose a new'ed GC:

"Application code must explicitly invoke the GC.dispose() method to
release the operating system resources managed by each instance when
those instances are no longer required."

You are using the constructor

public GC(Drawable drawable)

which has the explicit requirement

"You must dispose the graphics context when it is no longer required."

This seems a very strict requirement to me.

Eclipse has a very clear allocation policy here. For the same reason
you are not supposed to dispose any GC that you obtain as argument
of a specific event, like a PaintEvent event.



Yes, I realize now that GC should be explicitly disposed, you are right, I simply forgot that about GC. Not disposing it can cause potential memory leak. Thanks for reminding me!

So this error on Mac OS 10.6 is a consequence of my programming error.


Regards,

Albert
Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #492633 is a reply to message #492521] Wed, 21 October 2009 08:01 Go to previous messageGo to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Grant Gayed wrote on Tue, 20 October 2009 11:55
I've logged https://bugs.eclipse.org/bugs/show_bug.cgi?id=292780 .



Thank you, regards,

Albert

Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #523870 is a reply to message #492633] Mon, 29 March 2010 16:42 Go to previous messageGo to next message
Philip Borlin is currently offline Philip BorlinFriend
Messages: 30
Registered: July 2009
Member
I was having the "CGSDeviceSynchronize: Invalid device window" problem when I launched a second workbench window and then closed it in my RCP app (on OS X 10.6.2) I did a search for all of my GC instantiations, found 3 that weren't disposed of properly, disposed them properly, and the error went away.

Thanks for all the legwork Albert!
Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #527652 is a reply to message #523870] Thu, 15 April 2010 23:12 Go to previous messageGo to next message
Shane Martin is currently offline Shane MartinFriend
Messages: 1
Registered: April 2010
Junior Member
Philip Borlin wrote on Mon, 29 March 2010 12:42
I was having the "CGSDeviceSynchronize: Invalid device window" problem when I launched a second workbench window and then closed it in my RCP app (on OS X 10.6.2) I did a search for all of my GC instantiations, found 3 that weren't disposed of properly, disposed them properly, and the error went away.

Thanks for all the legwork Albert!


I'm having this issue and I don't know anything about a GC or how to find them -- I'm getting this error on the launch of eclipse. Perhaps it is different? Can someone run me through this?

[Updated on: Thu, 15 April 2010 23:15]

Report message to a moderator

Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #528903 is a reply to message #523870] Thu, 22 April 2010 11:01 Go to previous messageGo to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Philip Borlin wrote on Mon, 29 March 2010 12:42
I was having the "CGSDeviceSynchronize: Invalid device window" problem when I launched a second workbench window and then closed it in my RCP app (on OS X 10.6.2) I did a search for all of my GC instantiations, found 3 that weren't disposed of properly, disposed them properly, and the error went away.

Thanks for all the legwork Albert!


I'm glad to be helpful, regards,

Albert

Re: Strange error on Mac OS X 10.6 (Snow Leopard) with SWT 3.5 (Cocoa) [message #528906 is a reply to message #527652] Thu, 22 April 2010 11:10 Go to previous message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Shane Martin wrote on Thu, 15 April 2010 19:12
Philip Borlin wrote on Mon, 29 March 2010 12:42
I was having the "CGSDeviceSynchronize: Invalid device window" problem when I launched a second workbench window and then closed it in my RCP app (on OS X 10.6.2) I did a search for all of my GC instantiations, found 3 that weren't disposed of properly, disposed them properly, and the error went away.

Thanks for all the legwork Albert!


I'm having this issue and I don't know anything about a GC or how to find them -- I'm getting this error on the launch of eclipse. Perhaps it is different? Can someone run me through this?


Where is this error printed when starting Eclipse? Are you launching Eclipse from the Terminal window?

Otherwise, when programming with SWT, the following rules on resources disposal should be followed:

http://www.eclipse.org/articles/swt-design-2/swt-design-2.ht ml


Regards,

Albert
Previous Topic:Caret in StyledText won't hide
Next Topic:Whats wrong with the following tiny code using TreeEditor
Goto Forum:
  


Current Time: Fri Apr 19 03:14:03 GMT 2024

Powered by FUDForum. Page generated in 0.02863 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top