processing / processing/processing4
Initial Pause When Not Clearing in P2D and P3D Renderers
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 494
- 派生
- 183
- 平均合并
- 4 小时 39 分钟
- 30 天内合并 PR
- 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从提供的最小示例和测试示例开始,比较 P2D 和 P3D 在有无 background() 以及使用 PGraphics 缓冲区时的首帧时序。跟踪首帧涉及的 renderer 初始化和清除行为;当不调用 background() 时,测试示例不再出现报告中的数秒暂停,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- computer-graphics, performance
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100