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

Android: app freezes while waiting for al_acknowledge_drawing_halt() #1517

Closed
alemart opened this issue Dec 14, 2023 · 1 comment
Closed

Comments

@alemart
Copy link
Contributor

alemart commented Dec 14, 2023

Summary

An Android app may freeze while AllegroSurface.nativeOnDestroy() waits for a call to al_acknowledge_drawing_halt().

How to reproduce the issue

Open ex_android and keep switching the app in and out of context very quickly. Eventually the app will freeze. The issue is reproducible with other examples too.

Details

As can be seen below, method AllegroSurface.nativeOnDestroy() in android_display.c emits an ALLEGRO_EVENT_DISPLAY_HALT_DRAWING just before waiting for a condition variable that is signaled in android_acknowledge_drawing_halt(). The drawing halt event is handled in a different thread. If the order of operations is such that the event is handled (and the condition variable is signaled) before the other thread is waiting, the app will freeze. The signal is lost and does nothing. The freeze can be reproduced easily by adding an al_rest() call before al_wait_cond().

if (_al_event_source_needs_to_generate_event(&d->es)) {
ALLEGRO_EVENT event;
event.display.type = ALLEGRO_EVENT_DISPLAY_HALT_DRAWING;
event.display.timestamp = al_current_time();
_al_event_source_emit_event(&d->es, &event);
}
ALLEGRO_DEBUG("unlocking display event source");
_al_event_source_unlock(&d->es);
// wait for acknowledge_drawing_halt
al_lock_mutex(display->mutex);
al_wait_cond(display->cond, display->mutex);
al_unlock_mutex(display->mutex);

@dos1
Copy link
Contributor

dos1 commented Apr 15, 2024

Sounds like a duplicate of #959

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants