libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.22k stars 1.86k forks source link

testautomation on Android fails in SDL_aaudio.c #7573

Closed madebr closed 1 year ago

madebr commented 1 year ago

Running testautomation on Android fails when calling SDL_OpenAudioDevice at this location. When pressing break on the dialog, the same assertion triggers again when SDL_OpenAudioDevice is called again.

https://github.com/libsdl-org/SDL/blob/a874f6c9930603a1086869d4da28452caa4b5807/src/audio/aaudio/SDL_aaudio.c#L76-L82

(lldb) frame select 36
   76       LOGI(__func__);
   77   
   78       SDL_assert((captureDevice == NULL) || !iscapture);
-> 79       SDL_assert((audioDevice == NULL) || iscapture);
            ^
   80   
   81       if (iscapture) {
   82           if (!Android_JNI_RequestPermission("android.permission.RECORD_AUDIO")) {
(lldb) frame variable -A -g
(SDL_AssertData) sdl_assert_data = {
  always_ignore = 0
  trigger_count = 0
  condition = 0x0000007472e67ea0 "(captureDevice == ((void*)0)) || !iscapture"
  filename = 0x0000000000000000
  linenum = 0
  function = 0x0000000000000000
  next = NULL
}
(SDL_AssertData) sdl_assert_data = {
  always_ignore = 0
  trigger_count = 1
  condition = 0x0000007472e6b33a "(audioDevice == ((void*)0)) || iscapture"
  filename = 0x0000007472e77501 "/home/maarten/programming/SDL/src/audio/aaudio/SDL_aaudio.c"
  linenum = 79
  function = 0x0000007472e697b7 "aaudio_OpenDevice"
  next = NULL
}
(SDL_AudioDevice *) this = 0x00000074d1646c40
(const char *) devname = 0x00000074d161f2b8 "2"
(SDL_PrivateAudioData *) private = 0x0000007471c7a740
(SDL_bool) iscapture = SDL_FALSE
(aaudio_result_t) res = 2025387648
(const SDL_AssertState) sdl_assert_state = SDL_ASSERTION_ALWAYS_IGNORE | 0x72fc2028
(AudioBootStrap) aaudio_bootstrap = {
  name = 0x0000007472e78f18 "AAudio"
  desc = 0x0000007472e67ecc "AAudio audio driver"
  init = 0x0000007472fc8d10 (libSDL3.so`aaudio_Init at SDL_aaudio.c:270)
  demand_only = SDL_FALSE
}
(SDL_AudioDevice *) audioDevice = 0x00000074d1646060
(SDL_AudioDevice *) captureDevice = NULL
(AAUDIO_Data) ctx = {
  builder = 0x00000074d1623c70
  handle = 0xeb484aa60021707b
  AAudio_convertResultToText = 0x00000074d87ea5f8 (libaaudio.so`AAudio_convertResultToText)
  AAudio_convertStreamStateToText = 0x00000074d87ea5fc (libaaudio.so`AAudio_convertResultToText + 4)
  AAudio_createStreamBuilder = 0x00000074d87ea600 (libaaudio.so`AAudio_convertStreamStateToText + 4)
  AAudioStreamBuilder_setDeviceId = 0x00000074d87ea61c (libaaudio.so`AAudioStreamBuilder_setPerformanceMode + 4)
  AAudioStreamBuilder_setSampleRate = 0x00000074d87ea620 (libaaudio.so`AAudioStreamBuilder_setPerformanceMode + 8)
  AAudioStreamBuilder_setChannelCount = 0x00000074d87ea624 (libaaudio.so`AAudioStreamBuilder_setPerformanceMode + 12)
  AAudioStreamBuilder_setFormat = 0x00000074d87ea630 (libaaudio.so`AAudioStreamBuilder_setPerformanceMode + 24)
  AAudioStreamBuilder_setDirection = 0x00000074d87ea62c (libaaudio.so`AAudioStreamBuilder_setPerformanceMode + 20)
  AAudioStreamBuilder_setErrorCallback = 0x00000074d87ea610 (libaaudio.so`AAudioStreamBuilder_setErrorCallback)
  AAudioStreamBuilder_openStream = 0x00000074d87ea658 (libaaudio.so`AAudioStreamBuilder_setSampleRate + 56)
  AAudioStreamBuilder_delete = 0x00000074d87ea660 (libaaudio.so`AAudioStreamBuilder_delete)
  AAudioStream_close = 0x00000074d87ea688 (libaaudio.so`AAudioStream_close)
  AAudioStream_requestStart = 0x00000074d87ea68c (libaaudio.so`AAudioStream_close + 4)
  AAudioStream_requestPause = 0x00000074d87ea690 (libaaudio.so`AAudioStream_close + 8)
  AAudioStream_requestStop = 0x00000074d87ea698 (libaaudio.so`AAudioStream_close + 16)
  AAudioStream_getState = 0x00000074d87ea6a8 (libaaudio.so`AAudioStream_close + 32)
  AAudioStream_read = 0x00000074d87ea670 (libaaudio.so`AAudioStream_read)
  AAudioStream_write = 0x00000074d87ea678 (libaaudio.so`AAudioStream_write)
  AAudioStream_getXRunCount = 0x00000074d87ea6c4 (libaaudio.so`AAudioStream_close + 60)
  AAudioStream_getSampleRate = 0x00000074d87ea69c (libaaudio.so`AAudioStream_close + 20)
  AAudioStream_getChannelCount = 0x00000074d87ea6a0 (libaaudio.so`AAudioStream_close + 24)
  AAudioStream_getFormat = 0x00000074d87ea6ac (libaaudio.so`AAudioStream_close + 36)
  AAudioStream_getTimestamp = 0x00000074d87ea6f0 (libaaudio.so`AAudioStream_getFramesRead + 4)
}
1bsyl commented 1 year ago

@madebr can you try with this, ? seem a limitation to open multiple playback/capture at the same time. At least it shouldn't assert !

1bsyl commented 1 year ago

https://github.com/libsdl-org/SDL/commit/407b85c5060b5981bb9ef18079d526e93c95d39d

madebr commented 1 year ago

These make the tests run without triggering any assertion. Some audio tests still fail (and a clipboard + a few render ones). I disabled the video test suite because it caused the app to close prematurely.

~android-testautomation-2.txt~ android-testautomation-3.txt


10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01: Harness input to repro failures:
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter audio_openCloseAndGetAudioStatus
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter audio_lockUnlockOpenAudioDevice
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter audio_initOpenCloseQuitAudio
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter audio_pauseUnpauseAudio
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter clipboard_testClipboardTextFunctions
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter render_testPrimitives
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter render_testViewport
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter render_testLogicalSize
10-14 19:07:01.311 29811 11282 I SDL/TEST:  10/14/22 19:07:01:  --seed 6AAHOW1FA3ZQAL16 --filter surface_testSaveLoadBitmap
1bsyl commented 1 year ago

maybe that would improve aaudio backend: https://github.com/libsdl-org/SDL/pull/7587 ?

1bsyl commented 1 year ago

I re-run the audio test ( using seed RNAUALFYJ8NXIAEG) at start I got:

SDL/TEST: - date - : Assert Summary: Total=48 Passed=48 Failed=0
SDL/TEST: - date - : Assert Summary: Total=21 Passed=21 Failed=0
SDL/TEST: - date - : Assert Summary: Total=20 Passed=20 Failed=0
SDL/TEST: - date - : Assert Summary: Total=6 Passed=6 Failed=0
SDL/TEST: - date - : Assert Summary: Total=455 Passed=455 Failed=0
SDL/TEST: - date - : Assert Summary: Total=320 Passed=320 Failed=0
SDL/TEST: - date - : Assert Summary: Total=5 Passed=5 Failed=0
SDL/TEST: - date - : Assert Summary: Total=16 Passed=13 Failed=3
SDL/TEST: - date - : Assert Summary: Total=16 Passed=13 Failed=3
SDL/TEST: - date - : Assert Summary: Total=6 Passed=6 Failed=0
SDL/TEST: - date - : Assert Summary: Total=41 Passed=41 Failed=0
SDL/TEST: - date - : Assert Summary: Total=103 Passed=88 Failed=15
SDL/TEST: - date - : Assert Summary: Total=263 Passed=193 Failed=70
SDL/TEST: - date - : Assert Summary: Total=37 Passed=37 Failed=0
SDL/TEST: - date - : Suite Summary: Total=16 Passed=10 Failed=4 Skipped=2
SDL/TEST: - date - : Run Summary: Total=16 Passed=10 Failed=4 Skipped=2

after, the PR #7610

SDL/TEST: - date - : Assert Summary: Total=45 Passed=45 Failed=0
SDL/TEST: - date - : Assert Summary: Total=21 Passed=21 Failed=0
SDL/TEST: - date - : Assert Summary: Total=20 Passed=20 Failed=0
SDL/TEST: - date - : Assert Summary: Total=6 Passed=6 Failed=0
SDL/TEST: - date - : Assert Summary: Total=455 Passed=455 Failed=0
SDL/TEST: - date - : Assert Summary: Total=320 Passed=320 Failed=0
SDL/TEST: - date - : Assert Summary: Total=5 Passed=5 Failed=0
SDL/TEST: - date - : Assert Summary: Total=12 Passed=10 Failed=2
SDL/TEST:  -date - : Assert Summary: Total=12 Passed=10 Failed=2
SDL/TEST: - date - : Assert Summary: Total=6 Passed=6 Failed=0
SDL/TEST: - date - : Assert Summary: Total=41 Passed=41 Failed=0
SDL/TEST: - date - : Assert Summary: Total=103 Passed=88 Failed=15
SDL/TEST: - date - : Assert Summary: Total=263 Passed=193 Failed=70
SDL/TEST: - date - : Assert Summary: Total=37 Passed=37 Failed=0
SDL/TEST: - date - : Suite Summary: Total=16 Passed=10 Failed=4 Skipped=2
SDL/TEST: - date - : Run Summary: Total=16 Passed=10 Failed=4 Skipped=2

after, adding, also #7587:

SDL/TEST: - date - : Assert Summary: Total=45 Passed=45 Failed=0
SDL/TEST: - date - : Assert Summary: Total=21 Passed=21 Failed=0
SDL/TEST: - date - : Assert Summary: Total=20 Passed=20 Failed=0
SDL/TEST: - date - : Assert Summary: Total=6 Passed=6 Failed=0
SDL/TEST: - date - : Assert Summary: Total=455 Passed=455 Failed=0
SDL/TEST: - date - : Assert Summary: Total=320 Passed=320 Failed=0
SDL/TEST: - date - : Assert Summary: Total=5 Passed=5 Failed=0
SDL/TEST: - date - : Assert Summary: Total=18 Passed=18 Failed=0
SDL/TEST: - date - : Assert Summary: Total=18 Passed=18 Failed=0
SDL/TEST: - date - : Assert Summary: Total=6 Passed=6 Failed=0
SDL/TEST: - date - : Assert Summary: Total=41 Passed=41 Failed=0
SDL/TEST: - date - : Assert Summary: Total=103 Passed=103 Failed=0
SDL/TEST: - date - : Assert Summary: Total=263 Passed=263 Failed=0
SDL/TEST: - date - : Assert Summary: Total=37 Passed=37 Failed=0
SDL/TEST: - date - : Suite Summary: Total=16 Passed=14 Failed=0 Skipped=2
SDL/TEST: - date - : Run Summary: Total=16 Passed=14 Failed=0 Skipped=2

So it seems ok and better to merge !