Running test on appium android on several emulators. Using ThreadLocal to separate driver instances. Faced with problem when one of emulators always crashes on the same step.
After investigating I came to the conclusion that the reason is clipboard. One emulator clicks on the clipboard field and after some time the second do the same and crashes.
Java exception:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
Adb logs:
*** FATAL EXCEPTION IN SYSTEM PROCESS
java.lang.IllegalStateException: beginBroadcast() called while already in a broadcast
at android.os.RemoteCallbackList.beginBroadcast(RemoteCallbackList.java:241)
at com.android.server.clipboard.ClipboardService.setPrimaryClipInternal(ClipboardService.java:583)
at com.android.server.clipboard.ClipboardService$1.onHostClipboardUpdated(ClipboardService.java:205)
at com.android.server.clipboard.HostClipboardMonitor.run(ClipboardService.java:125)
at java.lang.Thread.run(Thread.java:919)
So my question is:
Thanks for help.
I solved the problem by resetting the clipboard right after anything was placed in it. Means immediately after clicking on the field.
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(null), null);