-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -291,7 +291,14 @@ - (instancetype)initWithPlayerItem:(AVPlayerItem *)item | |||
[self getVideoCompositionWithTransform:self->_preferredTransform | ||||
withAsset:asset | ||||
withVideoTrack:videoTrack]; | ||||
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. | ||||
@try { | ||||
item.videoComposition = videoComposition; | ||||
} @catch (NSException *exception) { | ||||
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. 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 commentThe 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 commentThe 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
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.
Please provide a link to the documentation that you are referring to here, so that we are all working from the same information.
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. |
||||
item.videoComposition = nil; | ||||
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. 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 commentThe 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 commentThe 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. |
||||
} | ||||
} | ||||
}; | ||||
[videoTrack loadValuesAsynchronouslyForKeys:@[ @"preferredTransform" ] | ||||
|
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.