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 GAPIR Android app termination #2657

Merged
merged 3 commits into from
Mar 11, 2019
Merged
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
27 changes: 21 additions & 6 deletions cmd/gapir/cc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,31 +374,46 @@ void android_main(struct android_app* app) {

app->onAppCmd = android_process;

bool finishing = false;
bool alive = true;
while (alive) {
int fdesc;
int events;
const int timeoutMilliseconds = 1000;
struct android_poll_source* source;
while (ALooper_pollAll(1000, &fdesc, &events, (void**)&source) >= 0) {
while (ALooper_pollAll(timeoutMilliseconds, &fdesc, &events,
(void**)&source) >= 0) {
// process this event
if (source) {
source->process(app, source);
}
if (app->destroyRequested) {
unlink(socket_file_path.c_str());
// Clean up and exit the main loop
server->shutdown();
alive = false;
break;
}
}

if (serverIsDone) {
unlink(socket_file_path.c_str());
alive = false;
if (serverIsDone && !finishing) {
// Start termination of the app
ANativeActivity_finish(app->activity);
hevrard marked this conversation as resolved.
Show resolved Hide resolved

// Note that we need to keep on polling events, eventually APP_CMD_DESTROY
// will pop-up after which app->destroyRequested will be true, enabling us
// to properly exit the main loop.

// Meanwhile, remember that we are finishing to avoid calling
// ANativeActivity_finish() several times.
finishing = true;
}
}

// Final clean up
waiting_thread.join();
ANativeActivity_finish(app->activity);
unlink(socket_file_path.c_str());
GAPID_INFO("End of Graphics API Replay");
return;
hevrard marked this conversation as resolved.
Show resolved Hide resolved
}

#else // TARGET_OS == GAPID_OS_ANDROID
Expand Down