| Summary: | AbstractUIPlugin is not thread-safe | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Randy Hudson <hudsonr> |
| Component: | UI | Assignee: | Platform-UI-Inbox <Platform-UI-Inbox> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | pwebster, remy.suen |
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
|
Description
Randy Hudson
Please see the entry in the Eclipse help under
Platform Plug-in Developer Guide >
Programmer's Guide >
Standard Widget Toolkit >
Threading issues
Unless specified, all processing is assumed to be done on the UI thread.
Such a general statement like that is silly. When you drive into the state of North Carolina, it says "Speed limit 55 unless otherwise posted", but good luck using that as an excuse for speeding. If something must be done on the UI thread, you will see this in the javadoc: * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread... You can create images on any thread. We are using SWT to render stuff onto Images on a server, which are then displayed by web browsers. Our server has to handle multiple requests in parallel. Making our code work on the server has been unnecessarily difficult. I've had to create my own ThreadSafeResourceManager and other replacements. The same help document also says "SWT will trigger an SWTException for any calls made from a non-UI thread that must be made from the UI thread". Images are resources, but they are not UI. You can construct Images, Fonts, Colors, GCs, Patterns, Regions, and other resources on any thread. On the help page that I pointed to ( http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/swt_threading.htm ) please see this line: "a platform UI library should not be considered thread-safe unless it is specifically documented as such". This is a design principle for the Platform UI code. If you don't believe me, see bug 79492, bug 58315 . In addition to that, OK, let's imagine we change AbstractUIPlugin#getImageRegistry() to be "thread-safe". What does that mean for the ImageRegistry class? Do we now need to make it thread-safe too? How about the following entry in its Javadoc: * An image registry owns all of the image objects registered * with it, and automatically disposes of them when the SWT Display * that creates the images is disposed. Because of this, clients do not * need to (indeed, must not attempt to) dispose of these images themselves. This is not an invalid request. I've already have this working in my own code, and I verified with an SWT team member that threading restrictions only apply to the User Interface (UI), which includes Displays, and the Widget hierarchy. Images are not UI. |