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

Fixed bug #9792 - Android: build failure / deprecated ALooper_pollAll #9807

Merged
merged 1 commit into from
May 16, 2024

Conversation

1bsyl
Copy link
Contributor

@1bsyl 1bsyl commented May 16, 2024

Fixed bug #9792 - Android: build failure with ndk 27-beta1 of deprecated ALooper_pollAll
replace ALooper_pollAll by ALooper_pollOnce

not tested ! but that replace the call to pollAll() with while() { .. pollOnce() }

…due to use of deprecated ALooper_pollAll

replace ALooper_pollAll by ALooper_pollOnce
@madebr
Copy link
Contributor

madebr commented May 16, 2024

I'm not sure this has something to do with my phone, or SDL, but often I can't get testautomation to finish.
It often quits in video_setWindowCenteredOnDisplay with the following message:

05-16 16:30:06.865  4665  4665 V SDL     : onStop()
05-16 16:30:06.871  4665  4665 I Choreographer: Skipped 31 frames!  The application may be doing too much work on its main thread.

If it finishes, the following tests fail:

05-16 16:31:02.510  4773  4796 I SDL/TEST:  05/16/24 16:31:02:  --seed ET23JN4UAQ9CHAAA --filter clipboard_testClipboardDataFunctions
05-16 16:31:02.510  4773  4796 I SDL/TEST:  05/16/24 16:31:02:  --seed ET23JN4UAQ9CHAAA --filter clipboard_testClipboardTextFunctions
05-16 16:31:02.510  4773  4796 I SDL/TEST:  05/16/24 16:31:02:  --seed ET23JN4UAQ9CHAAA --filter surface_testSaveLoadBitmap
05-16 16:31:02.510  4773  4796 I SDL/TEST:  05/16/24 16:31:02:  --seed ET23JN4UAQ9CHAAA --filter video_setWindowCenteredOnDisplay
05-16 16:31:02.510  4773  4796 I SDL/TEST:  05/16/24 16:31:02:  --seed ET23JN4UAQ9CHAAA --filter video_getSetWindowState

Do you see something similar? If so, then I'll create an issue.

About this pr. I don't see a change in behavior in a few test apps. So LGTM!

@slouken
Copy link
Collaborator

slouken commented May 16, 2024

I'll go ahead and merge this, but the timeout probably shouldn't be -1. We can resolve that in a future commit.

Thanks!

@slouken slouken merged commit ee16d2f into libsdl-org:main May 16, 2024
38 checks passed
@1bsyl
Copy link
Contributor Author

1bsyl commented May 16, 2024

@madebr
the message
Choreographer: Skipped 31 frames! The application may be doing too much work says this going to be an ANR.
the testautomation is a testsuite, without interaction and the activity is somehow freezed.

We would need to do some PollEvent between tests. maybe a basic while loop to deplete the events in between test suites ?
(if needed between sub tests, but some test need the events .. )

SDL_test_harness.c: line 518. while (SDL_PollEvent(&e) == 1) { };

@madebr
Copy link
Contributor

madebr commented May 16, 2024

I think Android required both frequent event polling and updating the window.
When I start the test again, it continues where it stopped.

I don't think (solely) adding a SDL_PollEvent to SDL_test_harness.c is the correct solution as I can regularly cause a segfault after a "restart" whereas current main simply finishes.

backtrace:
      #00 pc 00000000002251fc  /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/lib/arm64/libSDL3.so (Android_PumpEvents_Blocking+84) (BuildId: 0a4eb099ae19b0752c29f0c94239eca76262a1fc)
      #01 pc 00000000000a851c  /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/lib/arm64/libSDL3.so (SDL_PumpEventsInternal+96) (BuildId: 0a4eb099ae19b0752c29f0c94239eca76262a1fc)
      #02 pc 00000000000a86b0  /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/lib/arm64/libSDL3.so (SDL_WaitEventTimeoutNS+144) (BuildId: 0a4eb099ae19b0752c29f0c94239eca76262a1fc)
      #03 pc 00000000000a8610  /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/lib/arm64/libSDL3.so (SDL_PollEvent+24) (BuildId: 0a4eb099ae19b0752c29f0c94239eca76262a1fc)
      #04 pc 000000000009f144  /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/lib/arm64/libtestautomation.so (SDLTest_RunSuites+1432) (BuildId: 91cfaf1a13075080d0a13bedf24705e819e465d1)
      #05 pc 000000000005a504  /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/lib/arm64/libtestautomation.so (SDL_main+1172) (BuildId: 91cfaf1a13075080d0a13bedf24705e819e465d1)
      #06 pc 00000000001e6c88  /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/lib/arm64/libSDL3.so (Java_org_libsdl_app_SDLActivity_nativeRunMain+848) (BuildId: 0a4eb099ae19b0752c29f0c94239eca76262a1fc)
      #07 pc 000000000021a354  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 0c537e5efe426a30e9fde84241db9e3e)
      #08 pc 0000000000209398  /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 0c537e5efe426a30e9fde84241db9e3e)
      #09 pc 000000000000cd10  [anon:dalvik-classes.dex extracted in memory from /data/app/~~RM-oNxfIWiBvL1zG9zjhUQ==/org.libsdl.sdl.test.testautomation-Jza6t3syWhFTBuav-3KXBw==/base.apk] (org.libsdl.app.SDLMain.run+168)
      #10 pc 000000000020b074  /apex/com.android.art/lib64/libart.so (nterp_helper+7540) (BuildId: 0c537e5efe426a30e9fde84241db9e3e)
      #11 pc 00000000000efeac  /apex/com.android.art/javalib/core-oj.jar (java.lang.Thread.run+8)
      #12 pc 000000000021096c  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+556) (BuildId: 0c537e5efe426a30e9fde84241db9e3e)
      #13 pc 000000000027975c  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+184) (BuildId: 0c537e5efe426a30e9fde84241db9e3e)
      #14 pc 0000000000603a10  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+460) (BuildId: 0c537e5efe426a30e9fde84241db9e3e)
      #15 pc 000000000064ac98  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1288) (BuildId: 0c537e5efe426a30e9fde84241db9e3e)
      #16 pc 00000000000b63b0  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 2c82bf49529e9aa25cb9e5eca777a56f)
      #17 pc 00000000000530b8  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 2c82bf49529e9aa25cb9e5eca777a56f)

@1bsyl
Copy link
Contributor Author

1bsyl commented May 17, 2024

Not sure it really need a screen refresh, but we can try.
also, usually the polling doesn't need to be extra frequent (for a test suite). anr should come after a few sec. I mean it's more about 1sec than 1 ms.

but maybe it needs, a dummy window in between suites, otherwise it doesm't really pump the events, and the activity could be stucked

SDL_CreateWindow()
while (SDL_PollEvent(&e) == 1) { };
SDL_Delay(1000);
SDL_Destroy();

also, there are the issue of calling init / quit multiple time:
#7591
quick work around:

src/video/android/SDL_androidvideo.c:
//     device->GL_UnloadLibrary = Android_GLES_UnloadLibrary;

@MoNTE48
Copy link

MoNTE48 commented Aug 10, 2024

Any chance to get this ee16d2f commit backport-ed to SDL2 branch?

@slouken
Copy link
Collaborator

slouken commented Aug 10, 2024

Any chance to get this ee16d2f commit backport-ed to SDL2 branch?

It's already done.

@MoNTE48
Copy link

MoNTE48 commented Aug 13, 2024

The 2.26.5 release is still impossible to build with NDK r27

@madebr
Copy link
Contributor

madebr commented Aug 13, 2024

The 2.26.5 release is still impossible to build with NDK r27

2.26 is not maintained anymore, use a release >= 2.30.x

@MoNTE48
Copy link

MoNTE48 commented Aug 13, 2024

Typo. 2.30.6

@madebr
Copy link
Contributor

madebr commented Aug 13, 2024

Typo. 2.30.6

The fix is in the 2.30.x branch, but is not yet part of an official release.
4222ceb

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

Successfully merging this pull request may close these issues.

4 participants