Sporadic lag in Android game

谁说胖子不能爱 提交于 2019-12-12 10:59:34

问题


I'm making a simple Android game with Java. I noticed some annoying lags every 20-40 seconds. First I thought they we're caused by the Garbage Collector, but as I checked my LogCat I saw that there's no Garbage Collection at the time the game lags. I marked the log everytime the game begans to lag and saw that there's almost everytime this log entry:

W/qdhwcomposer(209): Excessive delay reading vsync: took 47 ms

As it says, there is a delay (usually >45ms) and i think that's what I notice as lag. Does anybody know this problem or how to avoid those delays?



Here are two snippets from LogCat at the time the game lags:

07-29 15:11:50.196: D/BatteryService(692): update start
07-29 15:11:50.206: D/BatteryService(692): level:80, scale:100, status:2, health:2, present:true, voltage: 4121, temperature: 355, technology: Li-ion, AC powered:false, USB powered:true, Wireless powered:false, icon:17303554, invalid charger:0, online:4, charge type:1, current avg:460
07-29 15:11:50.206: D/BatteryService(692): Sending ACTION_BATTERY_CHANGED.
07-29 15:11:50.216: D/STATUSBAR-BatteryController(1082): onReceive() - ACTION_BATTERY_CHANGED
07-29 15:11:50.216: D/STATUSBAR-BatteryController(1082): onReceive() - BATTERY_STATUS_CHARGING:
07-29 15:11:50.226: D/HeadsetStateMachine(18054): Disconnected process message: 10
07-29 15:11:50.236: W/qdhwcomposer(209): Excessive delay reading vsync: took 47 ms
07-29 15:11:50.236: D/STATUSBAR-IconMerger(1082): checkOverflow(288), More:true, Req:true Child:5

07-29 15:12:00.176: W/qdhwcomposer(209): Excessive delay reading vsync: took 49 ms
07-29 15:12:00.226: D/BatteryService(692): update start
07-29 15:12:00.226: D/BatteryService(692): level:80, scale:100, status:2, health:2, present:true, voltage: 4065, temperature: 355, technology: Li-ion, AC powered:false, USB powered:true, Wireless powered:false, icon:17303554, invalid charger:0, online:4, charge type:1, current avg:460
07-29 15:12:00.226: D/BatteryService(692): Sending ACTION_BATTERY_CHANGED.
07-29 15:12:00.236: D/STATUSBAR-BatteryController(1082): onReceive() - ACTION_BATTERY_CHANGED
07-29 15:12:00.236: D/STATUSBAR-BatteryController(1082): onReceive() - BATTERY_STATUS_CHARGING:
07-29 15:12:00.236: D/HeadsetStateMachine(18054): Disconnected process message: 10



I tested it with Android 4.3 on my Samsung Galaxy S4 (GT-I9505) btw.

Thanks
Geru


回答1:


Try debugging the app using -http://developer.android.com/tools/debugging/debugging-tracing.html



来源:https://stackoverflow.com/questions/25017352/sporadic-lag-in-android-game

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!