MCPcopy Create free account
hub / github.com/cocos/cocos-engine / loop

Method loop

native/cocos/platform/android/AndroidPlatform.cpp:853–898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

851}
852
853int32_t AndroidPlatform::loop() {
854 IXRInterface *xr = CC_GET_XR_INTERFACE();
855 while (true) {
856 struct android_poll_source *source;
857
858 // suspend thread while _loopTimeOut set to -1
859 while (ALooper_pollOnce(_loopTimeOut, nullptr, nullptr,
860 reinterpret_cast<void **>(&source)) >= 0) {
861 // Process event
862 if (source != nullptr) {
863 source->process(_app, source);
864 }
865
866 // Exit the game loop when the Activity is destroyed
867 if (_app->destroyRequested) {
868 break;
869 }
870 }
871 // Exit the game loop when the Activity is destroyed
872 if (_app->destroyRequested) {
873 break;
874 }
875 if (xr && !xr->platformLoopStart()) continue;
876 _inputProxy->handleInput();
877 if (_inputProxy->isAnimating() && (xr ? xr->getXRConfig(xr::XRConfigKey::SESSION_RUNNING).getBool() : true)) {
878 runTask();
879 if (_inputProxy->isActive()) {
880 flushTasksOnGameThreadAtForegroundJNI();
881 }
882 }
883 flushTasksOnGameThreadJNI();
884
885#if CC_ENABLE_SUSPEND_GAME_THREAD
886 if (_isLowFrequencyLoopEnabled) {
887 // Suspend a game thread after it has been running in the background for a specified amount of time
888 if (_lowFrequencyTimer.getSeconds() > LOW_FREQUENCY_EXPIRED_DURATION_SECONDS) {
889 _isLowFrequencyLoopEnabled = false;
890 _loopTimeOut = -1;
891 }
892 }
893#endif
894 if (xr) xr->platformLoopEnd();
895 }
896 onDestroy();
897 return 0;
898}
899
900void AndroidPlatform::pollEvent() {
901 //

Callers

nothing calls this directly

Calls 12

platformLoopStartMethod · 0.80
handleInputMethod · 0.80
isAnimatingMethod · 0.80
getBoolMethod · 0.80
getXRConfigMethod · 0.80
getSecondsMethod · 0.80
platformLoopEndMethod · 0.80
onDestroyFunction · 0.50
processMethod · 0.45
isActiveMethod · 0.45

Tested by

no test coverage detected