processing / processing/processing4
Initial Pause When Not Clearing in P2D and P3D Renderers
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 494
- Fork
- 183
- Merge medio
- 4h 39m
- PR unite (30g)
- 3
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con gli sketch minimo e di test forniti, confrontando il timing del primo frame per P2D e P3D con e senza background() e con i buffer PGraphics. Traccia l’inizializzazione e la cancellazione del renderer coinvolte nel primo frame; il lavoro è completato quando lo sketch di test non mostra più la pausa di diversi secondi segnalata quando background() non viene chiamato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- computer-graphics, performance
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100