2012-09-02 35 views
1

我正在使用OpenGL ES 1.1和CADisplayLink爲3d場景設置動畫效果。如果最近iOS設備已經重新啓動,則動畫非常平滑,兩個displayLink.timestamp調用之間的時間差異相當均勻。但是在使用iOS設備幾個小時或幾天後,我的應用程序有時會運行幾次,動畫會變得不穩定,並且時間差值會逐漸增大,然後重置爲較低的值,以便再次提升。使用CADisplayLink的iOS OpenGL ES 1.1生澀動畫(重新啓動修復了一段時間)

像這樣:

2012-09-01 23:42:58.770 [2678:707] DT = 0.021139

2012-09-01 23:42:58.787 [2678: 707] DT = 0.022183

2012-09-01 23:42:58.804 [2678:707] DT = 0.023223

2012-09-01 23:42:58.820 [2678:707] DT = 0.024270

2012-09-01 23:42:58.837 [2678:707] DT = 0.009679

2012-09-01 23:42:58.853 [2678:707] DT = 0.010750

2012-09- 01 23:42:58.870 [2678:707] DT = 0.011766

2012-09-01 23:42:58.887 [2678:707] DT = 0.012806

2012-09-01 23:42:58.903 [2678:707] dt = 0.013847

2012-09-01 23:42:58.920 [2678:707] dt = 0.014890

2012-09-01 23:42:58.937 [2678:707] DT = 0.015933

2012-09-01 23:42:58.953 [2678:707] DT = 0.016976

2012-09 -01 23:42:58.970 [2678:707] DT = 0.018011

2012-09-01 23:42:58.987 [2678:707] DT = 0.019055

2012-09-01 23點42: 59.003 [2678:707] dt = 0.020097

2012-09-01 23:42:59.020 [2678:707] dt = 0.021143

2012-09-01 23:42:59.037 [2678:707] DT = 0.022181

2012-09-01 23:42:59.054 [2678:707] DT = 0.023222

2012- 09-01 23:42:59.071 [2678:707] DT = 0.024288

2012-09-01 23:42:59.087 [2678:707] DT = 0.009624

2012-09-01 23點42分:59.103 [2678:707] dt = 0.010728

2012-09-01 23:42:5 9.121 [2678:707] DT = 0.011763

2012-09-01 23:42:59.137 [2678:707] DT = 0.012808

2012-09-01 23:42:59.153 [2678:707] dt = 0。013847

2012-09-01 23:42:59170 [2678:707] DT = 0.014891

2012-09-01 23:42:59187 [2678:707] DT = 0.016002

2012 -09-01 23:42:59203 [2678:707] DT = 0.016979

2012-09-01 23:42:59220 [2678:707] DT = 0.018016

2012-09-01 23: 42:59237 [2678:707] DT = 0.019042

2012-09-0 1 23:42:59253 [2678:707] DT = 0.020099

2012-09-01 23:42:59270 [2678:707] DT = 0.021138

2012-09-01 23:42:59287 [2678:707] DT = 0.022185

2012-09-01 23:42:59304 [2678:707] DT = 0.023222

2012-09-01 23:42:59320 [2678:707] dt的= 0.024265

2012-09-01 23:42:59337 [2678:707] DT = 0.009681

2012-09-01 23:42:59354 [2678:707] DT = 0.010736

然後,如果iOS設備重新啓動動畫是平滑一次。

問題譚在我的屏幕菜單KHI發生相關的計算幾乎沒有遊戲中UpdateAnimation()函數回事。

我不明白是怎麼回事,爲什麼一個新鮮的重啓將永遠解決這個問題了一會兒。

+0

與時間探查器應用程序,你看不到任何熱點很明顯嗎? –

+0

@布拉德拉爾森,伊朗時間探查用倒置調用樹,我沒有看到任何東西,看起來像一個熱點給我。 – timthecoder

回答

4

發現問題!我使用從CADisplayLink時間戳來計算幀之間的時間。時間戳是雙的,但我(錯誤地)它GAN到浮子。這會導致精度損失,並導致錯誤的幀時間計算。生長從KHI用戶時間戳已重新啓動的設備,並得到最終相比它需要大到可用於雙準確地計算幀之間的時間的。如果您在使用倒CUA調用樹顫抖