Skip to content

Commit

Permalink
Removing future call from hideKeyboard to avoid leaks (mobile-dev-inc…
Browse files Browse the repository at this point in the history
  • Loading branch information
amanjeetsingh150 authored Jul 31, 2023
1 parent be3cdfc commit c2ac580
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions maestro-client/src/main/java/maestro/drivers/IOSDriver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class IOSDriver(
private val iosDevice: IOSDevice,
) : Driver {

private val executor by lazy { Executors.newSingleThreadExecutor() }
private val deviceInfo by lazy {
iosDevice.deviceInfo().expect {}
}
Expand Down Expand Up @@ -423,33 +422,25 @@ class IOSDriver(
override fun backPress() {}

override fun hideKeyboard() {
val future = executor.submit {
dismissKeyboardIntroduction()
dismissKeyboardIntroduction()

if (isKeyboardHidden()) return@submit
if (isKeyboardHidden()) return

swipe(
start = Point(widthPercentToPoint(0.5), heightPercentToPoint(0.5)),
end = Point(widthPercentToPoint(0.5), heightPercentToPoint(0.47)),
durationMs = 50,
)
swipe(
start = Point(widthPercentToPoint(0.5), heightPercentToPoint(0.5)),
end = Point(widthPercentToPoint(0.5), heightPercentToPoint(0.47)),
durationMs = 50,
)

if (isKeyboardHidden()) return@submit
if (isKeyboardHidden()) return

swipe(
start = Point(widthPercentToPoint(0.5), heightPercentToPoint(0.5)),
end = Point(widthPercentToPoint(0.47), heightPercentToPoint(0.5)),
durationMs = 50,
)
swipe(
start = Point(widthPercentToPoint(0.5), heightPercentToPoint(0.5)),
end = Point(widthPercentToPoint(0.47), heightPercentToPoint(0.5)),
durationMs = 50,
)

waitForAppToSettle(null, null)
}
try {
future.get(5, TimeUnit.SECONDS)
} catch (_: Exception) {
// swallow the timeout and exceptions
future.cancel(true)
}
waitForAppToSettle(null, null)
}

private fun isKeyboardHidden(): Boolean {
Expand Down

0 comments on commit c2ac580

Please sign in to comment.