Skip to content
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

[camera] fix camera video codec validation #13341

Merged
merged 4 commits into from
Jun 21, 2021
Merged

Conversation

ajsmth
Copy link
Contributor

@ajsmth ajsmth commented Jun 18, 2021

Why

The record session block was still being executed after the rejection callback had already fired - this PR prevents this from happening

How

The check is done inside the async block to ensure the state of movieFileOutput is accurate. If it's nil then the session is invalid and we shouldn't continue with the record session

Test Plan

Test suite for Camera passes

@ajsmth ajsmth requested a review from cruzach June 18, 2021 16:55
@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Jun 18, 2021
Copy link
Collaborator

@expo-bot expo-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review previously left here is no longer valid, jump to the latest one 👉 #13341 (review)

Copy link
Collaborator

@expo-bot expo-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review previously left here is no longer valid, jump to the latest one 👉 #13341 (review)

@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Jun 18, 2021
return;
// it is possible that the session has been invalidated at this point
// for example, the video codec option is invalid and so this call has already rejected
if (self.movieFileOutput != nil) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the promise always guaranteed to be rejected at this point if movieFileOutput is nil? this seems potentially fragile if not, we would leave a promise dangling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a very good point - thank you! I'll rework this

@ajsmth ajsmth requested a review from brentvatne June 18, 2021 20:56
Copy link
Collaborator

@expo-bot expo-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review previously left here is no longer valid, jump to the latest one 👉 #13341 (review)

@@ -509,7 +511,8 @@ - (void)record:(NSDictionary *)options resolve:(UMPromiseResolveBlock)resolve re
}

if (_movieFileOutput != nil && !_movieFileOutput.isRecording && _videoRecordedResolve == nil && _videoRecordedReject == nil) {

// Reset validation flag
_isValidRecordingConfig = YES;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make more sense to place this inside of the setVideoOptions method (in the future, maybe we'll add a call to that method somewhere else, in which case we'd want to reset _hasValidRecordingConfig to YES then, too)

@@ -534,6 +537,12 @@ - (void)record:(NSDictionary *)options resolve:(UMPromiseResolveBlock)resolve re
UM_WEAKIFY(self);
dispatch_async(self.sessionQueue, ^{
UM_STRONGIFY(self);
// it is possible that the session has been invalidated at this point
// for example, the video codec option is invalid and so this call has already rejected
if (!self.isValidRecordingConfig) {
Copy link
Contributor

@cruzach cruzach Jun 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nitpicky: I think "RecordingConfig" from isValidRecordingConfig and "VideoOptions" from setVideoOptions are referring to the same thing, so it would be good to pick one way to refer to it and stick to that

Copy link
Contributor

@bbarthec bbarthec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me 👍

Copy link
Collaborator

@expo-bot expo-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review previously left here is no longer valid, jump to the latest one 👉 #13341 (review)

@ajsmth ajsmth force-pushed the andrew/camera-testsuite-fix branch from 2105f7a to 86f028c Compare June 21, 2021 18:05
Copy link
Collaborator

@expo-bot expo-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

Looks like I have nothing to complain about 👏 Keep up the good work! 💪

Generated by ExpoBot 🤖 against 86f028c

@ajsmth ajsmth merged commit 0c6fcee into master Jun 21, 2021
@ajsmth ajsmth deleted the andrew/camera-testsuite-fix branch June 21, 2021 19:45
prakashbask pushed a commit to prakashbask/expo that referenced this pull request Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Appearance bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants