-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[video_player] Fix appleos crash when set negative video composition #7050
[video_player] Fix appleos crash when set negative video composition #7050
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Thanks for the contribution!
- I added new tests to check the change I am making, or this PR is test-exempt.
Where is this new test?
item.videoComposition = videoComposition; | ||
// Invalid values of video composition will throws an exception | ||
// (https://github.com/flutter/flutter/issues/151031). | ||
// When there is a problem with the parameters of video composition, set nil. |
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.
Where is the invalid video composition value coming from? If it's user input, this is very late in the code to be enforcing anything about it.
// When there is a problem with the parameters of video composition, set nil. | ||
@try { | ||
item.videoComposition = videoComposition; | ||
} @catch (NSException *exception) { |
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.
Unless it's impossible to know in advance that a value is invalid for some reason, creating an exception and then catching it is not correct behavior. Invalid arguments are a programming error, not a runtime error, so the plugin code should never be calling this with invalid arguments in the first place.
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.
In this plugin, invalid parameters may be caused by renderSize of videoCompositiom, but there are multiple cases in the documentation. However if we know that the parameter is abnormal, should we still let it be created successfully? I don't think setting invalid videoComposition is necessary for the creation process.
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.
However, we should check the validity of videoComposition in this function. Still, we want to determine if the creation process should be interrupted.
Line 211 in 754de19
- (AVMutableVideoComposition *)getVideoCompositionWithTransform:(CGAffineTransform)transform |
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.
there are multiple cases in the documentation
Please provide a link to the documentation that you are referring to here, so that we are all working from the same information.
However if we know that the parameter is abnormal, should we still let it be created successfully? I don't think setting invalid videoComposition is necessary for the creation process.
Please see my other unanswered question about whether the invalid values are coming from. Until there's an answer to that, there's no way to answer questions about how they should be handled. Bad values that come from plugin clients are very different from bad values that come from uncontrolled external video date, both of which are very different from bad values coming from a programming error in the plugin itself.
@try { | ||
item.videoComposition = videoComposition; | ||
} @catch (NSException *exception) { | ||
item.videoComposition = nil; |
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.
Errors, especially if they are ultimately caused by input from plugin clients, should never be silently ignored.
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.
I agree, as i said earlier, if we know that the parameter is abnormal, should we still let it be created successfully? If the creation process is to continue, there should be no other way than to set fake data and not set it at all. Or just return an error back to flutter?
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.
As above; we cannot answer this question without more information about the cause of the error.
|
If we don't know enough to construct a plausible test case that would reproduce the exception in a test, then we don't know enough to fix the issue. If we do, then then the test should do that. Either way, please don't check a checkbox for something you haven't actually done, as it makes things more difficult for reviewers. The checklist should reflect the actual state of the PR. |
Thank you, i miss something. |
From triage: @lxhlzyh are you still planning on updating this PR per the discussion above? |
Thank you for your contribution. I'm going to close this PR for now since there are outstanding comments, just to get this off our PR review queue. Please don't hesitate to submit a new PR if you have the time to address the review comments. Thanks! |
iOS/macOS crash when set negative video composition, we should catch this exception.
Fixes flutter/flutter#151031
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.