mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 17:12:40 +01:00
DroidFish: Don't run GTB initialization and engine startup in parallel. Seems to trigger ICS bug, see http://stackoverflow.com/questions/8688382/runtime-exec-bug-hangs-without-providing-a-process-object.
This commit is contained in:
@@ -46,4 +46,7 @@ public class EngineUtil {
|
||||
|
||||
/** Executes chmod 744 exePath. */
|
||||
final static native boolean chmod(String exePath);
|
||||
|
||||
/** For synchronizing non thread safe native calls. */
|
||||
public static Object nativeLock = new Object();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,9 @@ public class ExternalEngine extends UCIEngineBase {
|
||||
copyFile(engineFileName, new File(exePath));
|
||||
chmod(exePath);
|
||||
ProcessBuilder pb = new ProcessBuilder(exePath);
|
||||
engineProc = pb.start();
|
||||
synchronized (EngineUtil.nativeLock) {
|
||||
engineProc = pb.start();
|
||||
}
|
||||
|
||||
startupThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,8 @@ package org.petero.droidfish.gtb;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.petero.droidfish.engine.EngineUtil;
|
||||
|
||||
/** Interface to native gtb probing code. */
|
||||
class GtbProbe {
|
||||
static {
|
||||
@@ -38,6 +40,9 @@ class GtbProbe {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Sleep 0.5s to increase probability that engine
|
||||
// is initialized before TB.
|
||||
try { Thread.sleep(500); } catch (InterruptedException e) { }
|
||||
initIfNeeded();
|
||||
}
|
||||
});
|
||||
@@ -52,7 +57,9 @@ class GtbProbe {
|
||||
path = tbPathQueue.poll();
|
||||
if (path != null) {
|
||||
currTbPath = path;
|
||||
init(currTbPath);
|
||||
synchronized (EngineUtil.nativeLock) {
|
||||
init(currTbPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user