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

Bug 328847

Summary: [Help][Context] Eclipse Help performs http requests from UI thread
Product: [Eclipse Project] Platform Reporter: Christophe Cornu <christophe.cornu+eclipse>
Component: User AssistanceAssignee: platform-ua-inbox <platform-ua-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: cgold, ChrisAustin, daniel_megert, john.camelon
Version: 3.5.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard: stalebug

Description Christophe Cornu CLA 2010-10-27 11:39:51 EDT
Our code adds an SWT Link to a dialog. That link invokes the contextual help as follow.

        Link link = new Link(parent, SWT.NONE);
        link.setText(Messages.ConflictsPromptDialog_5);
        link.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {             PlatformUI.getWorkbench().getHelpSystem().displayHelp(IHelpContextIds.HELP_CONTEXT_HOWTORESOLVECONFLICTS_TUTORIAL);
            }
        });

displayHelp is invoked from the UI thread. I'm surprised to see it performs http requests from the UI thread. Shouldn't it be using a separate thread for this? Should we avoid that API? Thanks for tips.

at java/net/SocketInputStream.socketRead0(Native Method)
at java/net/SocketInputStream.read(SocketInputStream.java:141)
at java/io/BufferedInputStream.fill(BufferedInputStream.java:230(Compiled Code))
at java/io/BufferedInputStream.read1(BufferedInputStream.java:270(Compiled Code))
at java/io/BufferedInputStream.read(BufferedInputStream.java:329(Compiled Code))
at sun/net/www/http/HttpClient.parseHTTPHeader(HttpClient.java:688)
at sun/net/www/http/HttpClient.parseHTTP(HttpClient.java:633)
at sun/net/www/protocol/http/HttpURLConnection.getInputStream(HttpURLConnection.java:1067)
at java/net/HttpURLConnection.getResponseCode(HttpURLConnection.java:385)
at org/eclipse/help/internal/base/remote/RemoteContextProvider.getContext(RemoteContextProvider.java:57)
at org/eclipse/help/internal/context/ContextManager.getContext(ContextManager.java:85)
at org/eclipse/help/HelpSystem.getContext(HelpSystem.java:49)
at org/eclipse/ui/internal/help/WorkbenchHelpSystem.displayHelp(WorkbenchHelpSystem.java:922)
Comment 1 Chris Goldthorpe CLA 2010-10-27 16:19:14 EDT
I notice that remote help is being called and it looks as thought the remote content is being read on the UI thread, which as you say can cause the UI to block waiting for the http request.
Comment 2 Christophe Cornu CLA 2010-10-27 16:29:46 EDT
Is this API meant to be called from a UI thread or non UI thread?
PlatformUI.getWorkbench().getHelpSystem().displayHelp
Comment 3 Chris Goldthorpe CLA 2010-10-27 16:36:43 EDT
I think you were calling it correctly, usually it would be called from a UI thread. The problem is that Eclipse should be reading the context help data on a background thread and displaying it in the UI thread, which is not happening.
Comment 4 Chris Goldthorpe CLA 2011-03-04 17:37:19 EST
Fixing this would require changes to the way Platform UI interacts with the help system, allowing the help system to create a context whose evaluation was deferred so the processing could occur on a non UI thread. There is not time to do this work for Eclipse 3.7.
Comment 5 Lars Vogel CLA 2019-11-08 04:37:28 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant please remove the stalebug whiteboard tag.