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: deadlock after al_acknowledge_drawing_halt #959

Open
dos1 opened this Issue Nov 4, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@dos1
Copy link
Contributor

dos1 commented Nov 4, 2018

This seems like a race condition of some sorts: when I do some stuff (disable audio etc.) when handling ALLEGRO_EVENT_DISPLAY_HALT_DRAWING, it's hard to trigger, but when I move this stuff earlier (to ALLEGRO_EVENT_DISPLAY_SWITCH_OUT) it gets easier.

Basically, sometimes Allegro seems to be stuck waiting for al_acknowledge_drawing_halt even though it gets called.

Logs from case where it deadlocked:

11-02 04:31:27.330 31645 31645 D AllegroActivity: onPause
11-02 04:31:27.341 31645 31645 D AllegroActivity: onPause end
11-02 04:31:27.341 31645 31664 D Animatch: [HandleEvent] ALLEGRO_EVENT_DISPLAY_SWITCH_OUT
11-02 04:31:27.483 31645 31664 D Animatch: [PauseExecution] Engine halted.
11-02 04:31:27.483 31645 31664 D Animatch: [MainloopEvents] al_wait_for_event
11-02 04:31:27.527 31645 31645 D AllegroActivity: onSaveInstanceState
11-02 04:31:27.528 31645 31645 D AllegroActivity: onStop.
11-02 04:31:27.665 31645 31645 D AllegroSurface: surfaceDestroyed
11-02 04:31:27.665 31645 31664 D Animatch: [HandleEvent] ALLEGRO_EVENT_DISPLAY_HALT_DRAWING
11-02 04:31:27.666 31645 31664 D AllegroEGL: egl_clearCurrent
11-02 04:31:27.667 31645 31664 D AllegroEGL: egl_clearCurrent done
11-02 04:31:28.667 31645 31664 D Animatch: [MainloopEvents] al_wait_for_event

11-02 04:31:37.524  2369  2398 W ActivityManager: Activity stop timeout for ActivityRecord{e97a94e u0 com.holypangolin.Animatch/net.dosowisko.libsuperderpy.Activity t3172}
11-02 04:31:37.525  2369  2398 I ActivityManager: Activity reported stop, but no longer stopping: ActivityRecord{e97a94e u0 com.holypangolin.Animatch/net.dosowisko.libsuperderpy.Activity t3172}

Case where it didn't:

11-02 04:40:00.941 31957 31957 D AllegroActivity: onPause
11-02 04:40:00.944 31957 31957 D AllegroActivity: onPause end
11-02 04:40:00.957 31957 31976 D Animatch: [HandleEvent] ALLEGRO_EVENT_DISPLAY_SWITCH_OUT
11-02 04:40:01.117 31957 31976 D Animatch: [PauseExecution] Engine halted.
11-02 04:40:01.117 31957 31976 D Animatch: [MainloopEvents] al_wait_for_event
11-02 04:40:01.117 31957 31976 D Animatch: [MainloopEvents] al_wait_for_event
11-02 04:40:01.136 31957 31957 D AllegroActivity: onSaveInstanceState
11-02 04:40:01.138 31957 31957 D AllegroActivity: onStop.
11-02 04:40:01.159 31957 31957 D AllegroSurface: surfaceDestroyed
11-02 04:40:01.160 31957 31976 D Animatch: [HandleEvent] ALLEGRO_EVENT_DISPLAY_HALT_DRAWING
11-02 04:40:01.161 31957 31976 D AllegroEGL: egl_clearCurrent
11-02 04:40:01.161 31957 31976 D AllegroEGL: egl_clearCurrent done
11-02 04:40:01.162 31957 31957 D AllegroEGL: destroying egl_Surface
11-02 04:40:01.219 31957 31957 D AllegroEGL: destroying egl_Context
11-02 04:40:01.220 31957 31957 D AllegroSurface: surfaceDestroyed end
11-02 04:40:02.161 31957 31976 D Animatch: [MainloopEvents] al_wait_for_event

Take notice how

11-02 04:40:01.162 31957 31957 D AllegroEGL: destroying egl_Surface
11-02 04:40:01.219 31957 31957 D AllegroEGL: destroying egl_Context
11-02 04:40:01.220 31957 31957 D AllegroSurface: surfaceDestroyed end

lines are missing from the first log. In both cases, user code gets into al_wait_for_event, but when it deadlocks, there are no further events appearing, and judging from the logs, the app seems to be stuck when stopping, not even reporting a successful stop back to the system (so the "unresponsive app" dialog kicks in).

Related places in the code:

al_wait_cond(display->cond, display->mutex);

/* XXX mutex? */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.