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

refactor!: rework remote config plugin #4186

Merged
merged 58 commits into from
Jan 14, 2021
Merged

refactor!: rework remote config plugin #4186

merged 58 commits into from
Jan 14, 2021

Conversation

kroikie
Copy link
Collaborator

@kroikie kroikie commented Nov 23, 2020

Description

Update remote config plugin to:

  • Add proper testing
  • Use platform interface

Related Issues

#4035

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@google-cla google-cla bot added the cla: yes label Nov 23, 2020
@kroikie kroikie marked this pull request as draft November 23, 2020 18:45
Copy link
Member

@Ehesp Ehesp left a comment

Choose a reason for hiding this comment

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

Looking good so far 👍 Few comments, however main things once it's ready are:

  • Error handling around the Method Channel calls so errors are passed as FirebaseExceptions (example)
  • Pub code comments

Copy link
Contributor

@IchordeDionysos IchordeDionysos left a comment

Choose a reason for hiding this comment

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

OMG thanks, I really like that a Remote config rework is coming soon 😍

@IchordeDionysos
Copy link
Contributor

This would also make this PR obsolete #2061.

Fixes #195

@kroikie
Copy link
Collaborator Author

kroikie commented Dec 28, 2020

@Ehesp you mentioned here that we should convert platform exceptions to Firebase exceptions. Do you think this should be done:

a: on all calls over the channel
b: on all dev visible calls over the channel
c: on all calls over the channel that can return an exception

WDYT?

@kroikie kroikie force-pushed the remote-config-rework branch from 80a21cc to 0eee980 Compare December 28, 2020 23:43
@kroikie kroikie marked this pull request as ready for review December 28, 2020 23:43
@kroikie kroikie changed the title [WIP] rework remote config plugin rework remote config plugin Dec 28, 2020
@kroikie kroikie changed the title rework remote config plugin refactor: rework remote config plugin Dec 29, 2020
@Ehesp
Copy link
Member

Ehesp commented Dec 29, 2020

@kroikie generally we do this when an error can be thrown from a user side-effect, so when there are calls over the bridge from a direct user action.

@kroikie kroikie changed the title refactor: rework remote config plugin refactor[firebase_remote_config]: rework remote config plugin Dec 30, 2020
@kroikie kroikie changed the title refactor[firebase_remote_config]: rework remote config plugin refactor: rework remote config plugin Dec 30, 2020
Copy link
Member

@Ehesp Ehesp left a comment

Choose a reason for hiding this comment

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

Looking good - few things commented on. @Salakar / @russellwheatley could you give the iOS a look over?

Copy link

@ncuillery ncuillery left a comment

Choose a reason for hiding this comment

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

In iOS, the example app crashes when fetching the config in airplane mode:

Stacktrace
2021-01-05 10:51:10.872634-0500 Runner[94569:3476689] Task <C1792643-7196-4EE5-BB54-0D9EC5DDF6EC>.<1> HTTP load failed, 0/0 bytes (error code: -1009 [1:50])
2021-01-05 10:51:10.877075-0500 Runner[94569:3476689] Task <C1792643-7196-4EE5-BB54-0D9EC5DDF6EC>.<1> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x6000026e79c0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <C1792643-7196-4EE5-BB54-0D9EC5DDF6EC>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <C1792643-7196-4EE5-BB54-0D9EC5DDF6EC>.<1>"
), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://firebaseinstallations.googleapis.com/v1/projects/flutterfire-cd2f7/installations/, NSErrorFailingURLKey=https://firebaseinstallations.googleapis.com/v1/projects/flutterfire-cd2f7/installations/, _kCFStreamErrorDomainKey=1}
2021-01-05 10:51:10.878082-0500 Runner[94569:3476281] *** Assertion failure in -[FlutterError initWithCode:message:details:], ../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm:105
2021-01-05 10:51:10.878134-0500 Runner[94569:3476477] 6.33.0 - [Firebase/RemoteConfig][I-RCN000073] Failed to get installations token. Error : Error Domain=com.firebase.installations Code=0 "(null)" UserInfo={NSUnderlyingError=0x6000026e0570 {Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x6000026e79c0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <C1792643-7196-4EE5-BB54-0D9EC5DDF6EC>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <C1792643-7196-4EE5-BB54-0D9EC5DDF6EC>.<1>"
), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://firebaseinstallations.googleapis.com/v1/projects/flutterfire-cd2f7/installations/, NSErrorFailingURLKey=https://firebaseinstallations.googleapis.com/v1/projects/flutterfire-cd2f7/installations/, _kCFStreamErrorDomainKey=1}}}.
2021-01-05 10:51:10.914839-0500 Runner[94569:3476281] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Code cannot be nil'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff20420af6 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff20177e78 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2042091f +[NSException raise:format:] + 0
	3   Foundation                          0x00007fff2077056a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   Flutter                             0x00000001089da9b7 -[FlutterError initWithCode:message:details:] + 244
	5   Flutter                             0x00000001089da8b1 +[FlutterError errorWithCode:message:details:] + 56
	6   Runner                              0x0000000107e47c6d +[FLTFirebasePlugin createFlutterErrorFromCode:message:optionalDetails:andOptionalNSError:] + 653
	7   Runner                              0x0000000107e49777 __57-[FLTFirebaseRemoteConfigPlugin handleMethodCall:result:]_block_invoke + 391
	8   Runner                              0x0000000107e4a5a9 __71-[FLTFirebaseRemoteConfigPlugin fetchAndActivate:withMethodCallResult:]_block_invoke + 121
	9   Runner                              0x0000000107def81c __57-[FIRRemoteConfig fetchAndActivateWithCompletionHandler:]_block_invoke + 332
	10  Runner                              0x0000000107e033b8 __65-[RCNConfigFetch reportCompletionOnHandler:withStatus:withError:]_block_invoke + 40
	11  libdispatch.dylib                   0x000000010a4117ec _dispatch_call_block_and_release + 12
	12  libdispatch.dylib                   0x000000010a4129c8 _dispatch_client_callout + 8
	13  libdispatch.dylib                   0x000000010a420e75 _dispatch_main_queue_callback_4CF + 1152
	14  CoreFoundation                      0x00007fff2038edbb __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	15  CoreFoundation                      0x00007fff2038963e __CFRunLoopRun + 2685
	16  CoreFoundation                      0x00007fff203886d6 CFRunLoopRunSpecific + 567
	17  GraphicsServices                    0x00007fff2bededb3 GSEventRunModal + 139
	18  UIKitCore                           0x00007fff24690e0b -[UIApplication _run] + 912
	19  UIKitCore                           0x00007fff24695cbc UIApplicationMain + 101
	20  Runner                              0x0000000107dc3ec0 main + 112
	21  libdyld.dylib                       0x00007fff202593e9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Code cannot be nil'
CoreSimulator 732.18.6 - Device: iPhone 11 (3AE4D40C-3A69-46F3-98C0-695EA67BF824) - Runtime: iOS 14.3 (18C61) - DeviceType: iPhone 11
terminating with uncaught exception of type NSException

To repro:

  1. Launch the example app on iOS device or simulator
  2. Turn to airplane mode (or turn off the laptop wifi if using the simulator)
  3. Tap on the fetch button

@kroikie kroikie force-pushed the remote-config-rework branch from a596b9f to 0c7d24f Compare January 5, 2021 19:00
@google-cla
Copy link

google-cla bot commented Jan 5, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jan 5, 2021
@kroikie kroikie force-pushed the remote-config-rework branch from e2927a1 to 6e52739 Compare January 12, 2021 17:18
@github-actions
Copy link

github-actions bot commented Jan 12, 2021

Visit the preview URL for this PR (updated for commit b146368):

https://flutter-firebase-docs--pr4186-remote-config-rework-i0k40rvu.web.app

(expires Tue, 19 Jan 2021 19:54:17 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@Salakar Salakar changed the title refactor: rework remote config plugin refactor!: rework remote config plugin Jan 12, 2021
@IchordeDionysos
Copy link
Contributor

@kroikie what are your plans with this PR? Do you plan to merge this PR with the reworked remote config API and in a second PR introduce support for the web.
Or do you plan to put web support in this PR as well?

Basically, my question is when you intend to merge/release the reworked plugin?

@google-cla
Copy link

google-cla bot commented Jan 12, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jan 12, 2021
@kroikie
Copy link
Collaborator Author

kroikie commented Jan 12, 2021

@IchordeDionysos the plan will be to land this update with the Platform Interface support then add web support in a follow up PR.

@google-cla
Copy link

google-cla bot commented Jan 12, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@Salakar
Copy link
Member

Salakar commented Jan 12, 2021

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Jan 12, 2021
@Salakar Salakar merged commit 20ab6c9 into master Jan 14, 2021
@Salakar Salakar deleted the remote-config-rework branch January 14, 2021 00:23
NSString *const kFirebaseRemoteConfigChannelName = @"plugins.flutter.io/firebase_remote_config";

@interface FLTFirebaseRemoteConfigPlugin ()
@property(nonatomic, retain) FlutterMethodChannel *channel;
Copy link
Contributor

Choose a reason for hiding this comment

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

this field is unused & could be removed.

It only seems to be set to nil in dealloc

@kroikie @rrousselGit

}
}

- (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will never be called because the plugin is not calling publish, per the API docs:

You will only receive this method if you registered your plugin instance with the `FlutterEngine` via `-[FlutterPluginRegistry publish:]`.

@firebase firebase locked and limited conversation to collaborators Feb 13, 2021
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.

7 participants