org.eclipse.swt.SWTException: Invalid thread access from HandledContributionItem - eclipse

I know there are lots of such questions here and most of them are answered. But the answers just won't solve my case.
I'm working on an eclipse plugin project, have a customized project type which can be either run or debugged. I have implemented the run and debug function and everything I expected are displayed on the screen, except the console shows an exception:
!ENTRY org.eclipse.e4.ui.workbench 4 0 2015-04-28 23:31:17.410
!MESSAGE Internal error during tool item enablement updating, this is only logged once per tool item.
!STACK 0
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4441)
at org.eclipse.swt.SWT.error(SWT.java:4356)
at org.eclipse.swt.SWT.error(SWT.java:4327)
at org.eclipse.swt.widgets.Widget.error(Widget.java:783)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:574)
at org.eclipse.swt.widgets.Widget.getData(Widget.java:874)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.updateIcons(HandledContributionItem.java:546)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.update(HandledContributionItem.java:440)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.update(HandledContributionItem.java:430)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$3.run(HandledContributionItem.java:168)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.updateItemEnablement(HandledContributionItem.java:196)
at org.eclipse.e4.ui.workbench.renderers.swt.ToolItemUpdater.updateContributionItems(ToolItemUpdater.java:39)
at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer$8.changed(ToolBarManagerRenderer.java:367)
at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:110)
at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:338)
at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:352)
at org.eclipse.ui.internal.services.EvaluationService.contextEvaluate(EvaluationService.java:139)
at org.eclipse.ui.internal.services.EvaluationService.addSourceProvider(EvaluationService.java:180)
at org.eclipse.debug.internal.ui.contexts.DebugContextSourceProvider.<init>(DebugContextSourceProvider.java:51)
at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService.<init>(DebugWindowContextService.java:62)
at org.eclipse.debug.internal.ui.contexts.DebugContextManager.createService(DebugContextManager.java:163)
at org.eclipse.debug.internal.ui.contexts.DebugContextManager.getContextService(DebugContextManager.java:221)
at org.eclipse.debug.internal.ui.views.ViewContextService.<init>(ViewContextService.java:620)
at org.eclipse.debug.internal.ui.views.ViewContextManager.windowOpened(ViewContextManager.java:93)
at org.eclipse.debug.internal.ui.views.ViewContextManager.<init>(ViewContextManager.java:55)
at org.eclipse.debug.internal.ui.views.ViewContextManager.getDefault(ViewContextManager.java:44)
at org.eclipse.debug.internal.ui.contexts.DebugContextManager.getDefault(DebugContextManager.java:150)
at org.eclipse.debug.ui.DebugUITools.getDebugContextManager(DebugUITools.java:1068)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupService.<init>(SourceLookupService.java:40)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupManager.windowOpened(SourceLookupManager.java:91)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupManager.<init>(SourceLookupManager.java:41)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupManager.getDefault(SourceLookupManager.java:53)
at org.eclipse.debug.internal.ui.DebugUIPlugin.initializeLaunchListeners(DebugUIPlugin.java:935)
at org.eclipse.debug.internal.ui.DebugUIPlugin.launchAdded(DebugUIPlugin.java:920)
at org.eclipse.debug.internal.core.LaunchManager$LaunchNotifier.run(LaunchManager.java:451)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.debug.internal.core.LaunchManager$LaunchNotifier.notify(LaunchManager.java:438)
at org.eclipse.debug.internal.core.LaunchManager.fireUpdate(LaunchManager.java:1044)
at org.eclipse.debug.internal.core.LaunchManager.addLaunch(LaunchManager.java:708)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:834)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
My codes are as following: In LaunchShortCut.java I have
Display.getDefault().syncExec(new Runnable() {
#Override
public void run() {
Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
if(DebugUITools.openLaunchConfigurationDialog(activeShell, config, group, null) == Window.CANCEL){
return;
}
}
});
This trigger the LaunchConfigurationWindow, and does not show any exception in console. When I hit the "run" in this window, the process stops at the first line in the following code where I have a breakpoint, and shows the exception in the console.
Display.getDefault().syncExec(new Runnable() {
#Override
public void run() {
//clear old output
HTMLOutput htmloutput = (HTMLOutput) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("my.view.id");
}
}
From the stack trace of the exception I don't see anything related to my code. If I let the program go on running, everything is fine, I don't see any trouble this exception causes, but I just can't figure what's it about and can't even stop it from showing up. Please help me on this issue.

It seems that you've hit a bug in Eclipse. The same stacktrace is described in Bug 445560. Chances are that the workaround described in this bug report (see comment 4) also helps in your case:
As current local workaround for this issue I've added in our rcp code an early call to DebugUITools.getDebugContextManager() from the UI thread.
Ugly, and should not be needed, but it avoids the failures seen when launching for the first time.

Related

UndeliverableException thrown within a RxAndroidBle stream

I have a misbehaving BLE device (temp sensor) that keeps throwing a status 8 (GATT_INSUF_AUTHORIZATION or GATT_CONN_TIMEOUT) exception everytime i try to connect to the device. I'm not concerned about this exception as the device is faulty.
However, I keep getting notified that i've not handled the error correctly by rxjava2 when using RxAndroidBle(1.9.1); see here;
This is my code.
rxBleClient
.getBleDevice(macAddress)
.establishConnection(false)
.flatMapSingle { it.readRssi() }
.subscribe({ "test1:Success" }, { "test1:error" })
and the Error
I/RxBle#GattCallback: MAC='E9:CF:8A:D0:01:19' onConnectionStateChange(), status=8, value=0
D/RxBle#ClientOperationQueue: FINISHED ConnectOperation(147547253) in 10257 ms
D/RxBle#ConnectionOperationQueue: Connection operations queue to be terminated (MAC='E9:CF:8A:D0:01:19')
com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='E9:CF:8A:D0:01:19' with status 8 (GATT_INSUF_AUTHORIZATION or GATT_CONN_TIMEOUT)
at com.polidea.rxandroidble2.internal.connection.RxBleGattCallback$2.onConnectionStateChange(RxBleGattCallback.java:77)
at android.bluetooth.BluetoothGatt$1$4.run(BluetoothGatt.java:249)
at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:725)
at android.bluetooth.BluetoothGatt.-wrap0(Unknown Source:0)
at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:244)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:70)
at android.os.Binder.execTransact(Binder.java:697)
D/BleDeviceManagerNew$observeRssiTest: test1:error
E/plication$setupApp: Terminal Exception From RXJAVA was Not handled correctly
io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='E9:CF:8A:D0:01:19' with status 8 (GATT_INSUF_AUTHORIZATION or GATT_CONN_TIMEOUT)
at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
at io.reactivex.internal.operators.observable.ObservableUnsubscribeOn$UnsubscribeObserver.onError(ObservableUnsubscribeOn.java:67)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onError(ObservableSubscribeOn.java:63)
I'm not sure what else I should do - i've implemented a 'catch all' solution but don't like this approach;
RxJavaPlugins.setErrorHandler { e -> Timber.e(e, "Terminal Exception From RXJAVA was Not handled correctly") }
but don't see that as a good solution as expected that i should be-able to handle exception on the steam. Any suggestions of where I went wrong?
Your code is fine. The library has a flaw that does not allow to achieve your desired behaviour. More on the topic is on this library's wiki page.
While it is possible to design an API that would not throw UndeliverableException it would need to have a separate error Observable or Completable for BluetoothAdapter turning off and a separate one for RxBleConnection disconnect. The user would be responsible to mix those into their chain appropriately.
Current API does not allow it.

Unity WebGL - Locating code that triggers Reflection.emit

I've run into the dreaded Reflection.emit issue in my webplayer build and am unable to locate what is triggering it. I'm currently commenting out code method by method and rebuilding to locate the cause and have narrowed it down to the below.
I'm not using JSON so the various JSON libraries aren't the cause, nor any of the other result suggestions returned by google.
How can i more easily go about locating the cause of this error. I have full stack trace on and well as full debugging, but all i get is the following console output.
NotSupportedException: C:\Program Files\Unity 2018.2.0b2\Editor\Data\il2cpp\libil2cpp\icalls\mscorlib\System.Reflection.Emit\AssemblyBuilder.cpp(20) : Unsupported internal call for IL2CPP:AssemblyBuilder::basic_init - System.Reflection.Emit is not supported.
Rethrow as TypeInitializationException: The type initializer for 'System.Reflection.Emit.DynamicMethod.AnonHostModuleHolder' threw an exception.
//NOTE: appM.procM is a C# .Net 4.x dynamic variable EG:
//public dynamic procM = GetProcClass(strProcName)
public void ShowProcList() {
/* Rest of method commented out*/
if(appM.procM == null){
procList.Initialize(appM.procM.lstNames, this);
}
/* Rest of method commented out*/
}
public void Initialize(List<string> lstNames, UIM um, string currProc=null) {
uiM = um;
//cleanup of the list before populating
foreach(Transform fld in Panel.transform) {
Destroy(fld.gameObject);
}
/* Rest of method commented out*/
}
Update: I narrowed down the problem line of code, but haven't closed the question as there's got to be an easier way than commenting out line by line and rebuilding.
For future searchers, the issue is the if(appM.procM == null) check. As procM is a dynamic variable reflection is used which kills AOT in webGL builds. No compiler warnings were generated to save myself from myself.
Nevermind, i am an idiot, The option Enable Exceptions under Player Settings was set to Full Without Stacktrace and not Full with Stacktrace.
The value Full With Stacktrace contains the pertinent data. Easily locatable in the browsers console. Warning that full debugging does increase build times and slow down the application.

Getting the stack trace of the error origin in swift

Consider this code:
func doSomething() throws {
try callThrowingFunction1()
try callThrowingFunction2()
}
func userAction() {
do {
try doSomething()
} catch {
// display and log error
}
}
Say those inner functions can throw the same kind of errors and I would like to know if an error occurred in callThrowingFunction1() or in callThrowingFunction2().
As long as I'm in the debugger I can set a breakpoint for Swift errors on swift_willThrow, but if I would like to log the call stack on a user device, is there a way to do that?
Swift errors have no such thing as stack-trace yet (if will ever), and even Xcode can show stack-trace only if the error is un-handled by our code (and gets caught by Xcode directly instead).
Alternativly, your custom Error's constructor can store the stack-trace for later use, but in most cases errors are not custom, where you can't alter error's constructor (like errors of 3rd-party library).
But we can at least print stack-trace of where error(s) get catched, like:
do {
try ... // something that throws goes here
} catch let error as NSError {
print("Error: \(error)")
println(NSThread.callStackSymbols())
}
Exception breakpoint
If you just want to debug, without need to upload stack-trace to server, then Xcode's "Exception breakpoint" feature can help, like:
First place a normal-breakpoint near the failing logic.
Wait until Xcode pauses App on that line, enable Xcode's feature:
Finally, resume App, and wait untill exception is thrown.
Images are old, nowadays you see "Add Swift Error Breakpoint" or something like that as well (beside "Add Exception Breakpoint" option).

Eclipse 4 rcp load layout not works with binding context

I have an application, in which I can save the load perspective layout.
Everything works until I add Binding Context to any Part. If I set Binding Context to part, then save layout, then close application and try to load layout in opened application again I get exception:
!ENTRY org.eclipse.e4.ui.workbench.swt 4 2 2016-10-16 20:54:37.922
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.e4.ui.workbench.swt".
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.IllegalArgumentException: A handle object may not have a null identifier
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:65)
at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:90)
at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:343)
at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:358)
at org.eclipse.e4.core.internal.contexts.EclipseContext.activate(EclipseContext.java:663)
at org.eclipse.e4.core.internal.contexts.EclipseContext.activateBranch(EclipseContext.java:669)
at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener$1.run(ShellActivationListener.java:95)
here is my steps:
test handler class:
public class Test {
#Execute
public void execute(EPartService partService) {
System.out.println("Test handler");
}
}
Create handler:
Then create Binding Contect, Binding table with KeyBinding
finally add BindingContext to part:
Loading and saving layout code is same as in this tutorial Model persistence article 3
Maybe someone knows what problem can be and is there are any solution?

Inconsistent output to Eclipse Console View

I am invoking a compiler command but the compiler messages are not getting displayed in the Eclipse Console View consistently.
I have my launch() method implemented the same way as first code block of
this question; I have the command-line string setup which I use to call DebugPlugin.exec() method. However, unlike the the author of the question above, my output Eclipse console is very inconsistent. T
There is no activity in the console when I invoke the command and the console continues to display the "No console to display at this time." But after invoking the command numerous time and activating different consoles from the drop-down menu, the console occasionally does become active and message is displayed.
I am confused with how the eclipse is behaving and not sure how to resolve this issue. Any comment and/or recommendation would be appreciated.
Thanks!!
--
EDIT
To add some more info, running the external process using External Tools works fine. I add the compiler process c:\path\myprocess.exe in Locations field and the file to compile in the Arguments field within the External Tools Configuration window. When I run it, all the output is displayed fine. It just won't display when I run it programmatically through LaunchConfigurationDelegate class.
Maybe try bringing the console to front programmatically see if it helps:
* Bring the console to front.
*/
public static void showConsole() {
Display.getDefault().asyncExec(new Runnable() {
#Override
public void run() {
IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IViewPart consoleView =
page.findView(IConsoleConstants.ID_CONSOLE_VIEW);
if (consoleView == null) {
IWorkbenchPart activePart = page.getActivePart();
try {
consoleView =
page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
} catch (PartInitException pie) {
CUIPlugin.log(pie);
}
// restore focus stolen by the creation of the
// console
page.activate(activePart);
} else {
boolean bringToTop = true;
if (bringToTop) {
page.bringToTop(consoleView);
}
}
}
}
}
});
}
Finally got it to work. The main change I've made is having my MyLaunchConfigurationDelegate extend LaunchConfigurationDelegate instead of just implementing ILaunchConfigurationDelegate. When observed through the debugger, the launch() method went through similar code path as external process that was launched via External Tools when MyLaunchConfigurationDelegate extended LaunchConfigurationDelegate.
I guess it was lack of information on my part but I wasn't sure which part of the code was more important to share.
Another piece of code that was removed was:
IProcess dbgProcess = DebugPlugin.newProcess(launch, compilerProcess, "XVR Compiler", processAttributes);
...
launch.removeProcess(dbgProcess);
I've added it while attempting different approach in debugging this issue and it actually caused more issues by removing the debugProcess before it has chance to display output to the console.