Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue when running shards on Android (#1853) #1998

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ object MaestroSessionManager {
val heartbeatFuture = executor.scheduleAtFixedRate(
{
try {
Thread.sleep(1000) // Add a 1-second delay here for fixing race condition
SessionStore.heartbeat(sessionId, selectedDevice.platform)
} catch (e: Exception) {
logger.error("Failed to record heartbeat", e)
Expand Down
5 changes: 5 additions & 0 deletions maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import java.net.URI
import java.util.UUID
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executors
import java.util.concurrent.Semaphore
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
import javax.xml.parsers.DocumentBuilderFactory
Expand All @@ -72,6 +73,7 @@ class AndroidDriver(
private val blockingStubWithTimeout get() = blockingStub.withDeadlineAfter(120, TimeUnit.SECONDS)
private val asyncStub = MaestroDriverGrpc.newStub(channel)
private val documentBuilderFactory = DocumentBuilderFactory.newInstance()
private val deviceCallSemaphore = Semaphore(1)

private var instrumentationSession: AdbShellStream? = null
private var proxySet = false
Expand Down Expand Up @@ -1093,6 +1095,7 @@ class AndroidDriver(
}

private fun <T> runDeviceCall(call: () -> T): T {
deviceCallSemaphore.acquire()
return try {
call()
} catch (throwable: StatusRuntimeException) {
Expand All @@ -1102,6 +1105,8 @@ class AndroidDriver(
throw MaestroException.DriverTimeout("Android driver unreachable")
}
throw throwable
} finally {
deviceCallSemaphore.release()
}
}

Expand Down
Binary file modified maestro-client/src/main/resources/maestro-app.apk
Binary file not shown.
Binary file modified maestro-client/src/main/resources/maestro-server.apk
Binary file not shown.
Loading