processing / processing/processing4

Initial Pause When Not Clearing in P2D and P3D Renderers

オープン
#642 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

help wanted opengl
主要言語
Java
スター
494
フォーク
183
平均マージ
4時間 39分
マージ済み PR(30日)
3

説明

Created by: JeremyEastham

Description

When rendering with either the P2D or P3D renderers, there is a noticeable pause on the first frame of the sketch if background is not called. Normally this pause is not very long, but this pause becomes more noticeable at higher resolutions and if multiple PGraphics objects are used as buffers.

Minimal Code to Reproduce

void setup()
{
  fullScreen( P2D );
}

void draw()
{
  fill( frameCount % 2 * 255 ); //Flash every odd frame
  rect( 0, 0, width, height );
  //A workaround would be to replace the above lines with background(...);
}

Testing Code

//Testing variables
boolean callBackground = false; //Toggle bug
boolean useBuffers = false;
int numBuffers = 2;

//Public variables
PGraphics[] buffers;
long startTime; //Time when setup returns

void setup()
{
  fullScreen( P2D ); //Also works with P3D
  background( 0 );
  noStroke();
  fill( 0 );
  if( useBuffers )
  {
    //Allocate buffers
    buffers = new PGraphics[numBuffers];
    for( int i = 0; i < numBuffers; i++ )
      buffers[i] = createGraphics( width, height, P2D );
  }
  //Record time before first frame
  startTime = millis();
}

void draw()
{
  if( frameCount == 1 ) //1st Frame
  {
    if( callBackground )
      background( 0 );
    else
      rect( 0, 0, width, height );
    if( useBuffers )
      for( PGraphics buffer : buffers )
      {
        buffer.beginDraw();
        if( callBackground )
          buffer.background( 0 );
        else
          buffer.rect( 0, 0, width, height );
        buffer.endDraw();
      }
  }
  
  if( frameCount == 2 ) //2nd Frame
  {
    long elapsed = millis() - startTime;
    fill( 255 );
    text( "2nd frame took " + elapsed + "ms", width / 2, height / 2 );
    println( elapsed + "ms" );
  }
}

With the testing code above, the amount of time to render the 2nd frame is ~40ms when callBackground is false and ~4000ms when callBackground is true (without buffers). Adding buffers increases the time by multiple seconds.

Your Environment

  • Processing version: 3.5.4 (have not tested with Processing 4)
  • Operating System and OS version: Windows 10.0.19043 Build 19043
  • Other information: Intel Core i5-10210U with Intel UHD Graphics 620

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供されている最小スケッチとテストスケッチから始め、background() と PGraphics バッファーの有無による P2D と P3D の初回フレームのタイミングを比較します。初回フレームに関係する renderer の初期化とクリア動作を追跡します。background() を呼び出さない場合に、テストスケッチで報告されている数秒間の一時停止が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
computer-graphics, performance
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。