openframeworks / openframeworks/openFrameworks
multiple cairo renderers threading suffers from global style state leaks
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
I am using a Cairo renderer with a background threaded drawing, of which I have 8 threads running.
There are several instances where the global style is referenced and therefor causes unpredictable behavior. For example in:
void ofCairoRenderer::draw(ofPath & shape){
....
c.a = shape.getStrokeColor().a/255. * ofGetStyle().color.a;
....
}
This causes frames to intermittently show up blank. @arturoc is this outside of the expected use of Cairo?
Here is a snippet on how it's being used
cairoRenderer.setupMemoryOnly(ofCairoRenderer::IMAGE, false, false, ofRectangle(0,0,videoPixels.getWidth(), videoPixels.getHeight()) );
cairoRenderer.setupGraphicDefaults();
cairoRenderer.background(0);
for (int i = 0; i < contours.size(); i++){
ofPath contourPath;
for(int p = 0; p < contours.getPolyline(i).getVertices().size(); p++){
contourPath.lineTo(contours.getPolyline(i).getVertices()[p]);
}
contourPath.close();
cairoRenderer.setColor(ofColor::white);
contourPath.setFillColor(ofColor::white);
cairoRenderer.draw(contourPath);
}
}
cairoRenderer.flush();
ofPixels resized = cairoRenderer.getImageSurfacePixels();
resized.setImageType(OF_IMAGE_COLOR);
resized.resize(faceTargetRectangle.getWidth(), faceTargetRectangle.getHeight(), OF_INTERPOLATE_BICUBIC);
resized.pasteInto(outputImage, faceTargetRectangle.x, faceTargetRectangle.y);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ofCairoRenderer::draw, especially the ofGetStyle().color access shown in the report, and trace other global-style references used by the Cairo renderer. Reproduce the memory-only renderer with multiple background drawing threads and verify that frames no longer intermittently appear blank.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100