-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fixes/black frames #8130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Fixes/black frames #8130
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add GLSL-based noise(vec2) function to p5.strands (processing#7897)
…onymousFunctionCallbackFix Fix inline anonymous functions causing a parsing error in p5.strands callbacks
…ms-instance Fix p5.strands uniform calls, add instance mode construct
Enhance p5.strands noise() to support noise(x, y) and 4-octave fractal noise
Adding docs for `code` in the refrence.
… clarity and consistency
Individual flags to disable part of FES by the user
- Add p5.esm.min.js output to rollup config with terser minification - Include p5.esm.min.js in package.json files field for npm publishing - Follows existing pattern of hidden sourcemaps for minified builds
Add minified ESM build output
Optimize bottlenecks in 2.0 code
Fix: allow single-arg atan() outside strands; add unit test
[p5.strands] Significant refactor for p5.strands
…a-docs Update createCamera docs since it no longer sets the active camera
Use FES internationalization within the minor version
Added tests for _sanitizeFontName function to validate font name sanitization rules.
…n-loadFont Comma included in load font
…ssage-fix typography error message fixes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎬 Fix: Remove black frames at start of saveGif recordings
📋 Summary
Fixes the issue where
saveGif()
generates 1-3 black frames at the beginning of GIF recordings in p5.js 2.0+. This occurs because frame capture begins before the canvas is properly initialized and rendered.🐛 Problem
When using
saveGif()
in p5.js 2.0+, the generated GIFs contain black frames at the start before the actual animation begins. This happens because:draw()
loop hasn't executed for the first frameExample:
Result: GIF starts with 2-3 black frames, then shows the animation.
✨ Solution
This PR implements the following fixes:
1. Initial Render for Clean Start
redraw()
call with a 50ms delay when starting from frame 02. New
startLoop
OptionAdds a new configuration option to control frame count behavior:
Benefits:
true
)millis()
override)3. Improved Frame Capture Logic
frameIterator
properly tracks both delay and capture phases4. Proper State Restoration
frameCount
before recordingframeCount
appropriately after recording🧪 Testing
Test Case 1: Default Mode (startLoop: true)
Expected: GIF starts from frame 0, NO black frames ✅
Test Case 2: Continue Mode (startLoop: false)
Expected: GIF starts from current frame, NO black frames ✅
Test Case 3: With Delay
Expected: 1-second delay, then starts from frame 0, NO black frames ✅
📝 Changes Made
Modified Files
src/image/loading_displaying.js
Key Changes
startLoop
parameter to options (default:true
)frameIterator
initialization fromnFramesDelay
to0
startLoop
valuestartLoop: true
if (frameIterator >= nFramesDelay)
conditionredraw()
to ensure frame completionframeCount
🔄 Backward Compatibility
✅ Fully backward compatible
startLoop
option is opt-in🎯 Related Issues
Closes #8124
🙏 Acknowledgments
Thanks to the maintainer feedback regarding the intentional frameCount reset behavior and future plans for timing state management. This implementation provides a foundation for extending to other timing functions like
millis()
in the future.Before (broken):
After (fixed):
💡 Future Enhancements
This change lays the groundwork for:
millis()
during recording (mentioned by maintainer)Checklist: