LoginSignup
1
0

More than 5 years have passed since last update.

EgretEngineのプチフリーズを調べる

Posted at

各フレームの処理をまるっと時間をはかり200msより遅くなったらログを出力してみる

Updateのコストを測定してログ出力

index.htmlで 60FPSに設定しているので、秒に60回呼び出されるはずの enterFrameの処理コストを調べる

Main.ts

  this.addEventListener(egret.Event.ENTER_FRAME, this.enterFrame, this);

  private enterFrame(t: number): boolean {
    const start = performance.now();
    :
    const cost = performance.now() - start;
    if (200 < cost) {
      egret.log(`Cost over: ${cost}`);
    }
    return true;
  }

そんなコストがかかる処理は発生していませんでした

Updateの外のコストを測定してログ出力

Main.ts
 private enterFrame(t: number): boolean {
    const start = performance.now();
    if (this.lastCalled !== -1) {
      const otherCost = start - this.lastCalled;
      if (100 < otherCost) {
        egret.log(`Other cost over: ${otherCost}`);
      }
    }
    :
    const end = performance.now();
    const cost = end - start;
    if (100 < cost) {
      egret.log(`Cost over: ${cost}`);
    }
    this.lastCalled = end;
    return true;
  }

そうするとやはりこんな感じで

IMG_2028.PNG

とおもったら!

50FPSだと20msですね、全部間違っているので修正したものはこちら
https://github.com/liberapp-inc/h5g-qiita-jump-and-run/commit/c1df90e2edd3128baec2f52dfd743fb679583fe0

こうやってみるとそもそも20msもギリギリな感じたまに処理落ちしてますね

IMG_2029.PNG

結論

原因はまだ突き止められていませんが、単純に Update内部の処理が重いという話ではなさそうです

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0