-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix VideoRecorderAppState garbled output on window resize #2608
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
Open
Copilot
wants to merge
10
commits into
master
Choose a base branch
from
copilot/fix-video-recorder-output
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bc4e690
Initial plan
Copilot 4fc1ff3
Implement reshape() method to handle window resizing in VideoRecorder…
Copilot af078eb
Apply same reshape() fix to Android VideoRecorderAppState
Copilot 99c9f18
Address code review feedback: add timeout and improve clarity
Copilot f781c98
Improve exception logging to include stack trace
Copilot 1e0bb05
Fix blocking main loop in reshape - use flag-based async approach
Copilot 53e97fd
Refactor to use per-resolution workers with automatic eviction
Copilot 80f89d3
Fix race condition in getWorker using computeIfAbsent
Copilot 86fc9c3
Add unit tests for VideoRecorderAppState resize functionality
Copilot fd46362
Simplify VideoRecorderAppState unit tests to avoid mock dependencies
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -269,6 +269,57 @@ public void initialize(RenderManager rm, ViewPort viewPort) { | |
|
|
||
| @Override | ||
| public void reshape(ViewPort vp, int w, int h) { | ||
| if (this.width == w && this.height == h) { | ||
| return; | ||
| } | ||
|
|
||
| this.width = w; | ||
| this.height = h; | ||
|
|
||
| // Wait for all work items to finish processing with timeout | ||
| if (freeItems != null) { | ||
| try { | ||
| long startTime = System.currentTimeMillis(); | ||
| long timeout = 5000; // 5 second timeout | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot same as the other appstate
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 1e0bb05. Applied the same non-blocking flag-based approach to the desktop version. |
||
| while (freeItems.size() < numCpus) { | ||
| if (System.currentTimeMillis() - startTime > timeout) { | ||
| Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.WARNING, | ||
| "Timeout waiting for work items to complete during reshape. Some frames may be lost."); | ||
| break; | ||
| } | ||
| Thread.sleep(10); | ||
| } | ||
| } catch (InterruptedException ex) { | ||
| Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.SEVERE, null, ex); | ||
| } | ||
| } | ||
|
|
||
| // Close the current writer and generate new filename for resized video | ||
| if (writer != null) { | ||
| try { | ||
| writer.finishAVI(); | ||
| Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.INFO, | ||
| "Window resized from {0}x{1} to {2}x{3}. Previous recording saved to: {4}", | ||
| new Object[]{writer.width, writer.height, w, h, file.getAbsolutePath()}); | ||
| } catch (Exception ex) { | ||
| Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.SEVERE, "Error closing video on reshape", ex); | ||
| } | ||
| writer = null; | ||
|
|
||
| // Generate a new filename for the resized video | ||
| String originalPath = file.getAbsolutePath(); | ||
| int dotIndex = originalPath.lastIndexOf('.'); | ||
| String basePath = dotIndex > 0 ? originalPath.substring(0, dotIndex) : originalPath; | ||
| String extension = dotIndex > 0 ? originalPath.substring(dotIndex) : ".avi"; | ||
| file = new File(basePath + "-" + (System.currentTimeMillis() / 1000) + extension); | ||
| } | ||
|
|
||
| // Recreate work items with new dimensions | ||
| freeItems.clear(); | ||
| usedItems.clear(); | ||
| for (int i = 0; i < numCpus; i++) { | ||
| freeItems.add(new WorkItem(w, h)); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot you are blocking the main loop here, this is not going to work... if you really need to wait , mark your intention with a boolean flag and then in the update look for whatever condition you want to wait for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 1e0bb05. Now using a flag-based approach: reshape() sets reshapePending flag, and preFrame() handles the actual resize when all work items are available (non-blocking check).