Android: Use ALooper_pollOnce instead of ALooper_pollAll

ALooper_pollAll can cause potential deadlocks.

These calls are only made by our test suites.

Bug: chromium:1464077
Change-Id: Id56c0db67e10d6df00c3e6b9126952ffa1d40d48
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4690382
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
This commit is contained in:
Geoff Lang
2023-07-17 11:49:13 -04:00
committed by Angle LUCI CQ
parent 0518a3ff4d
commit d40669bb4b

View File

@@ -171,6 +171,11 @@ static int32_t onInputEvent(struct android_app *app, AInputEvent *event)
return 0; // 0 == not handled
}
static bool validPollResult(int result)
{
return result >= 0 || result == ALOOPER_POLL_CALLBACK;
}
void android_main(struct android_app *app)
{
int events;
@@ -187,7 +192,8 @@ void android_main(struct android_app *app)
// Message loop, polling for events indefinitely (due to -1 timeout)
// Must be here in order to handle APP_CMD_INIT_WINDOW event,
// which occurs after AndroidWindow::initializeImpl(), but before AndroidWindow::messageLoop
while (ALooper_pollAll(-1, nullptr, &events, reinterpret_cast<void **>(&source)) >= 0)
while (
validPollResult(ALooper_pollOnce(-1, nullptr, &events, reinterpret_cast<void **>(&source))))
{
if (source != nullptr)
{