Skip to content

Conversation

@paulb777
Copy link
Member

@paulb777 paulb777 commented May 13, 2020

Fix #4740

Insure that minimumFetchInterval setting is applied before fetching. Otherwise there will be indeterministic behavior when trying to verify console changes in an app.

@paulb777
Copy link
Member Author

- (void)fetchWithCompletionHandler:(FIRRemoteConfigFetchCompletion)completionHandler { should be fixed.

More investigation still needed for

- (void)fetchWithExpirationDuration:(NSTimeInterval)expirationDuration
                  completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {

[self fetchWithExpirationDuration:_settings.minimumFetchInterval
completionHandler:completionHandler];
__block NSTimeInterval minimumFetchInterval;
dispatch_sync(_queue, ^{
Copy link
Contributor

@maksymmalyhin maksymmalyhin May 13, 2020

Choose a reason for hiding this comment

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

In general dispatch_sync should be avoided unless required because the more dispatch_sync is used the easier it is to introduce a deadlock even when modifying code not directly related. I wonder if it can be updated to either:

  1. Use atomic properties or _Atomic vars for variables involved in the race condition
  2. Use dispatch_async e.g. :
dispatch_async(_queue, ^{
  [self fetchWithExpirationDuration:self->_settings.minimumFetchInterval completionHandler:completionHandler];
}

EDITIED:

It looks like #2 should be better though it may require modification of fetchWithExpirationDuration... method to account for calling from the queue.

Copy link
Member

Choose a reason for hiding this comment

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

#2 is probably better as remote config's mutex lock is all guarded by this queue. The fetch is assigned to async again inside https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseRemoteConfig/Sources/RCNFetch.m#L139
So using another mechanism might be more expensive since we already have a queue just for that.

Copy link
Contributor

@maksymmalyhin maksymmalyhin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ryanwilson ryanwilson left a comment

Choose a reason for hiding this comment

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

LGTM on Travis green

@paulb777
Copy link
Member Author

Testing was done manually with the new API tests in #5602. They'll be merged once automation is added for them.

All other automated tests passed on commit before changelog update.

@paulb777 paulb777 merged commit d0c9ded into master May 13, 2020
@paulb777 paulb777 deleted the pb-rc-async branch May 13, 2020 18:20
@firebase firebase locked and limited conversation to collaborators Jun 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote Config fetchAndActivate does not honour minimumFetchInterval in RemoteConfigSettings

6 participants