{"action":"created","comment":{"url":"https://api.github.com/repos/flutter/engine/pulls/comments/212797164","pull_request_review_id":149508064,"id":212797164,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjc5NzE2NA==","diff_hunk":"@@ -41,18 +65,37 @@ - (void)addDelegate:(NSObject<FlutterPlugin>*)delegate {\n   if (isPowerOfTwo([_pluginDelegates count])) {\n     [_pluginDelegates compact];\n   }\n+\n+  for (const auto& selector : lifeCycleSelectors) {\n+    if ([delegate respondsToSelector:selector]) {\n+      auto& p = _selectorTable[selector];\n+      if (p.get() == nil) {\n+        p.reset([[NSPointerArray weakObjectsPointerArray] retain]);\n+      }\n+\n+      [p.get() addPointer:(__bridge void*)delegate];","path":"shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm","position":54,"original_position":54,"commit_id":"7eb8fa8a428780eeb71b7e16e5858aee26afebe3","original_commit_id":"7eb8fa8a428780eeb71b7e16e5858aee26afebe3","user":{"login":"mravn-google","id":22935389,"node_id":"MDQ6VXNlcjIyOTM1Mzg5","avatar_url":"https://avatars0.githubusercontent.com/u/22935389?v=4","gravatar_id":"","url":"https://api.github.com/users/mravn-google","html_url":"https://github.com/mravn-google","followers_url":"https://api.github.com/users/mravn-google/followers","following_url":"https://api.github.com/users/mravn-google/following{/other_user}","gists_url":"https://api.github.com/users/mravn-google/gists{/gist_id}","starred_url":"https://api.github.com/users/mravn-google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mravn-google/subscriptions","organizations_url":"https://api.github.com/users/mravn-google/orgs","repos_url":"https://api.github.com/users/mravn-google/repos","events_url":"https://api.github.com/users/mravn-google/events{/privacy}","received_events_url":"https://api.github.com/users/mravn-google/received_events","type":"User","site_admin":false},"body":"The lifespan of Flutter plugins should probably have been tied to that of the `FlutterViewController` with which they register and set up Dart/iOS communication through platform channels. In general, such Flutter views can be created and destroyed at will during the lifecycle of the app.\r\n\r\nHowever, for Flutter-only apps created using `flutter create foo`, the life span of _the_ Flutter view is the same as that of the application---which is why we ended up in the current situation where plugins register once and have support for responding to all app delegate calls.\r\n\r\nFor add2app scenarios in particular, this coupling of the app lifecycle with the Flutter view lifecycle via plugins will have to be broken, I think. A first step was taken in #5173 which made it possible to delay plugin registration until the first Flutter view is created. That doesn't necessarily disqualify the present PR, but indicates that it is a step in a larger refactoring to fix an early design error.","created_at":"2018-08-25T12:17:09Z","updated_at":"2018-08-25T12:19:51Z","html_url":"https://github.com/flutter/engine/pull/6086#discussion_r212797164","pull_request_url":"https://api.github.com/repos/flutter/engine/pulls/6086","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/flutter/engine/pulls/comments/212797164"},"html":{"href":"https://github.com/flutter/engine/pull/6086#discussion_r212797164"},"pull_request":{"href":"https://api.github.com/repos/flutter/engine/pulls/6086"}},"in_reply_to_id":212782731},"pull_request":{"url":"https://api.github.com/repos/flutter/engine/pulls/6086","id":210876768,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwODc2NzY4","html_url":"https://github.com/flutter/engine/pull/6086","diff_url":"https://github.com/flutter/engine/pull/6086.diff","patch_url":"https://github.com/flutter/engine/pull/6086.patch","issue_url":"https://api.github.com/repos/flutter/engine/issues/6086","number":6086,"state":"open","locked":false,"title":"Make `FlutterAppDelegate` respond to life cycle events dynamically","user":{"login":"jamesderlin","id":17391434,"node_id":"MDQ6VXNlcjE3MzkxNDM0","avatar_url":"https://avatars3.githubusercontent.com/u/17391434?v=4","gravatar_id":"","url":"https://api.github.com/users/jamesderlin","html_url":"https://github.com/jamesderlin","followers_url":"https://api.github.com/users/jamesderlin/followers","following_url":"https://api.github.com/users/jamesderlin/following{/other_user}","gists_url":"https://api.github.com/users/jamesderlin/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesderlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesderlin/subscriptions","organizations_url":"https://api.github.com/users/jamesderlin/orgs","repos_url":"https://api.github.com/users/jamesderlin/repos","events_url":"https://api.github.com/users/jamesderlin/events{/privacy}","received_events_url":"https://api.github.com/users/jamesderlin/received_events","type":"User","site_admin":false},"body":"Make `FlutterAppDelegate` respond to various application life cycle\r\nevents (e.g. `applicationDidEnterBackground:`,\r\n`applicationWillEnterForeground:`, etc.) dynamically by forwarding\r\nthem to the `FlutterPluginAppLifeCycleDelegate` only if a registered\r\nplugin wants it.  This avoids unnecessary runtime warnings (e.g.\r\nissue #9984).\r\n\r\n`FlutterPluginAppLifeCycleDelegate` now maintains an internal table\r\nmapping selectors to corresponding plugins, and it no longer iterates\r\nover all plugins for each event (at the cost of using additional\r\nspace).\r\n\r\nNote that empirical testing seems to indicate that iOS caches which\r\nparts of the `UIApplicationDelegate` protocol the application\r\nimplements.  This means that client applications now must call\r\n`-[FlutterAppDelegate addApplicationLifeCycleDelegate]` early in\r\napplication initialization (e.g. in the `-init` method) for plugins\r\nto receive life cycle events.\r\n\r\nThis change also greatly reduces the amount of code that should be\r\ncopied and pasted from `FlutterAppDelegate` if client applications\r\ncannot directly inherit from it.  Alternatively, it provides an\r\nexample for how client applications can use `FlutterAppDelegate` via\r\ncomposition rather than inheritance (issue #20709).","created_at":"2018-08-25T00:52:52Z","updated_at":"2018-08-25T12:19:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc475c10017912800a8eb78e22be4924a480002e","assignee":null,"assignees":[],"requested_reviewers":[{"login":"cbracken","id":351029,"node_id":"MDQ6VXNlcjM1MTAyOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/351029?v=4","gravatar_id":"","url":"https://api.github.com/users/cbracken","html_url":"https://github.com/cbracken","followers_url":"https://api.github.com/users/cbracken/followers","following_url":"https://api.github.com/users/cbracken/following{/other_user}","gists_url":"https://api.github.com/users/cbracken/gists{/gist_id}","starred_url":"https://api.github.com/users/cbracken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbracken/subscriptions","organizations_url":"https://api.github.com/users/cbracken/orgs","repos_url":"https://api.github.com/users/cbracken/repos","events_url":"https://api.github.com/users/cbracken/events{/privacy}","received_events_url":"https://api.github.com/users/cbracken/received_events","type":"User","site_admin":false},{"login":"sigurdm","id":8613953,"node_id":"MDQ6VXNlcjg2MTM5NTM=","avatar_url":"https://avatars1.githubusercontent.com/u/8613953?v=4","gravatar_id":"","url":"https://api.github.com/users/sigurdm","html_url":"https://github.com/sigurdm","followers_url":"https://api.github.com/users/sigurdm/followers","following_url":"https://api.github.com/users/sigurdm/following{/other_user}","gists_url":"https://api.github.com/users/sigurdm/gists{/gist_id}","starred_url":"https://api.github.com/users/sigurdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigurdm/subscriptions","organizations_url":"https://api.github.com/users/sigurdm/orgs","repos_url":"https://api.github.com/users/sigurdm/repos","events_url":"https://api.github.com/users/sigurdm/events{/privacy}","received_events_url":"https://api.github.com/users/sigurdm/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":487933577,"node_id":"MDU6TGFiZWw0ODc5MzM1Nzc=","url":"https://api.github.com/repos/flutter/engine/labels/cla:%20yes","name":"cla: yes","color":"0e8a16","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/flutter/engine/pulls/6086/commits","review_comments_url":"https://api.github.com/repos/flutter/engine/pulls/6086/comments","review_comment_url":"https://api.github.com/repos/flutter/engine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/flutter/engine/issues/6086/comments","statuses_url":"https://api.github.com/repos/flutter/engine/statuses/7eb8fa8a428780eeb71b7e16e5858aee26afebe3","head":{"label":"jamesderlin:jamesderlin/plugin-forward","ref":"jamesderlin/plugin-forward","sha":"7eb8fa8a428780eeb71b7e16e5858aee26afebe3","user":{"login":"jamesderlin","id":17391434,"node_id":"MDQ6VXNlcjE3MzkxNDM0","avatar_url":"https://avatars3.githubusercontent.com/u/17391434?v=4","gravatar_id":"","url":"https://api.github.com/users/jamesderlin","html_url":"https://github.com/jamesderlin","followers_url":"https://api.github.com/users/jamesderlin/followers","following_url":"https://api.github.com/users/jamesderlin/following{/other_user}","gists_url":"https://api.github.com/users/jamesderlin/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesderlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesderlin/subscriptions","organizations_url":"https://api.github.com/users/jamesderlin/orgs","repos_url":"https://api.github.com/users/jamesderlin/repos","events_url":"https://api.github.com/users/jamesderlin/events{/privacy}","received_events_url":"https://api.github.com/users/jamesderlin/received_events","type":"User","site_admin":false},"repo":{"id":137386250,"node_id":"MDEwOlJlcG9zaXRvcnkxMzczODYyNTA=","name":"flutter-engine","full_name":"jamesderlin/flutter-engine","owner":{"login":"jamesderlin","id":17391434,"node_id":"MDQ6VXNlcjE3MzkxNDM0","avatar_url":"https://avatars3.githubusercontent.com/u/17391434?v=4","gravatar_id":"","url":"https://api.github.com/users/jamesderlin","html_url":"https://github.com/jamesderlin","followers_url":"https://api.github.com/users/jamesderlin/followers","following_url":"https://api.github.com/users/jamesderlin/following{/other_user}","gists_url":"https://api.github.com/users/jamesderlin/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesderlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesderlin/subscriptions","organizations_url":"https://api.github.com/users/jamesderlin/orgs","repos_url":"https://api.github.com/users/jamesderlin/repos","events_url":"https://api.github.com/users/jamesderlin/events{/privacy}","received_events_url":"https://api.github.com/users/jamesderlin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jamesderlin/flutter-engine","description":"The Flutter engine","fork":true,"url":"https://api.github.com/repos/jamesderlin/flutter-engine","forks_url":"https://api.github.com/repos/jamesderlin/flutter-engine/forks","keys_url":"https://api.github.com/repos/jamesderlin/flutter-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jamesderlin/flutter-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jamesderlin/flutter-engine/teams","hooks_url":"https://api.github.com/repos/jamesderlin/flutter-engine/hooks","issue_events_url":"https://api.github.com/repos/jamesderlin/flutter-engine/issues/events{/number}","events_url":"https://api.github.com/repos/jamesderlin/flutter-engine/events","assignees_url":"https://api.github.com/repos/jamesderlin/flutter-engine/assignees{/user}","branches_url":"https://api.github.com/repos/jamesderlin/flutter-engine/branches{/branch}","tags_url":"https://api.github.com/repos/jamesderlin/flutter-engine/tags","blobs_url":"https://api.github.com/repos/jamesderlin/flutter-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jamesderlin/flutter-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jamesderlin/flutter-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/jamesderlin/flutter-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jamesderlin/flutter-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/jamesderlin/flutter-engine/languages","stargazers_url":"https://api.github.com/repos/jamesderlin/flutter-engine/stargazers","contributors_url":"https://api.github.com/repos/jamesderlin/flutter-engine/contributors","subscribers_url":"https://api.github.com/repos/jamesderlin/flutter-engine/subscribers","subscription_url":"https://api.github.com/repos/jamesderlin/flutter-engine/subscription","commits_url":"https://api.github.com/repos/jamesderlin/flutter-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/jamesderlin/flutter-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/jamesderlin/flutter-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/jamesderlin/flutter-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/jamesderlin/flutter-engine/contents/{+path}","compare_url":"https://api.github.com/repos/jamesderlin/flutter-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jamesderlin/flutter-engine/merges","archive_url":"https://api.github.com/repos/jamesderlin/flutter-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jamesderlin/flutter-engine/downloads","issues_url":"https://api.github.com/repos/jamesderlin/flutter-engine/issues{/number}","pulls_url":"https://api.github.com/repos/jamesderlin/flutter-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/jamesderlin/flutter-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/jamesderlin/flutter-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jamesderlin/flutter-engine/labels{/name}","releases_url":"https://api.github.com/repos/jamesderlin/flutter-engine/releases{/id}","deployments_url":"https://api.github.com/repos/jamesderlin/flutter-engine/deployments","created_at":"2018-06-14T17:02:02Z","updated_at":"2018-07-21T00:32:06Z","pushed_at":"2018-08-25T00:50:21Z","git_url":"git://github.com/jamesderlin/flutter-engine.git","ssh_url":"git@github.com:jamesderlin/flutter-engine.git","clone_url":"https://github.com/jamesderlin/flutter-engine.git","svn_url":"https://github.com/jamesderlin/flutter-engine","homepage":"http://flutter.io","size":126839,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"flutter:master","ref":"master","sha":"308709014912db7e2832123a6312b3390ba70728","user":{"login":"flutter","id":14101776,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2","avatar_url":"https://avatars3.githubusercontent.com/u/14101776?v=4","gravatar_id":"","url":"https://api.github.com/users/flutter","html_url":"https://github.com/flutter","followers_url":"https://api.github.com/users/flutter/followers","following_url":"https://api.github.com/users/flutter/following{/other_user}","gists_url":"https://api.github.com/users/flutter/gists{/gist_id}","starred_url":"https://api.github.com/users/flutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flutter/subscriptions","organizations_url":"https://api.github.com/users/flutter/orgs","repos_url":"https://api.github.com/users/flutter/repos","events_url":"https://api.github.com/users/flutter/events{/privacy}","received_events_url":"https://api.github.com/users/flutter/received_events","type":"Organization","site_admin":false},"repo":{"id":39211337,"node_id":"MDEwOlJlcG9zaXRvcnkzOTIxMTMzNw==","name":"engine","full_name":"flutter/engine","owner":{"login":"flutter","id":14101776,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2","avatar_url":"https://avatars3.githubusercontent.com/u/14101776?v=4","gravatar_id":"","url":"https://api.github.com/users/flutter","html_url":"https://github.com/flutter","followers_url":"https://api.github.com/users/flutter/followers","following_url":"https://api.github.com/users/flutter/following{/other_user}","gists_url":"https://api.github.com/users/flutter/gists{/gist_id}","starred_url":"https://api.github.com/users/flutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flutter/subscriptions","organizations_url":"https://api.github.com/users/flutter/orgs","repos_url":"https://api.github.com/users/flutter/repos","events_url":"https://api.github.com/users/flutter/events{/privacy}","received_events_url":"https://api.github.com/users/flutter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flutter/engine","description":"The Flutter engine","fork":false,"url":"https://api.github.com/repos/flutter/engine","forks_url":"https://api.github.com/repos/flutter/engine/forks","keys_url":"https://api.github.com/repos/flutter/engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flutter/engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flutter/engine/teams","hooks_url":"https://api.github.com/repos/flutter/engine/hooks","issue_events_url":"https://api.github.com/repos/flutter/engine/issues/events{/number}","events_url":"https://api.github.com/repos/flutter/engine/events","assignees_url":"https://api.github.com/repos/flutter/engine/assignees{/user}","branches_url":"https://api.github.com/repos/flutter/engine/branches{/branch}","tags_url":"https://api.github.com/repos/flutter/engine/tags","blobs_url":"https://api.github.com/repos/flutter/engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flutter/engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flutter/engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/flutter/engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flutter/engine/statuses/{sha}","languages_url":"https://api.github.com/repos/flutter/engine/languages","stargazers_url":"https://api.github.com/repos/flutter/engine/stargazers","contributors_url":"https://api.github.com/repos/flutter/engine/contributors","subscribers_url":"https://api.github.com/repos/flutter/engine/subscribers","subscription_url":"https://api.github.com/repos/flutter/engine/subscription","commits_url":"https://api.github.com/repos/flutter/engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/flutter/engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/flutter/engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/flutter/engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/flutter/engine/contents/{+path}","compare_url":"https://api.github.com/repos/flutter/engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flutter/engine/merges","archive_url":"https://api.github.com/repos/flutter/engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flutter/engine/downloads","issues_url":"https://api.github.com/repos/flutter/engine/issues{/number}","pulls_url":"https://api.github.com/repos/flutter/engine/pulls{/number}","milestones_url":"https://api.github.com/repos/flutter/engine/milestones{/number}","notifications_url":"https://api.github.com/repos/flutter/engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flutter/engine/labels{/name}","releases_url":"https://api.github.com/repos/flutter/engine/releases{/id}","deployments_url":"https://api.github.com/repos/flutter/engine/deployments","created_at":"2015-07-16T17:39:56Z","updated_at":"2018-08-25T08:33:55Z","pushed_at":"2018-08-25T08:33:52Z","git_url":"git://github.com/flutter/engine.git","ssh_url":"git@github.com:flutter/engine.git","clone_url":"https://github.com/flutter/engine.git","svn_url":"https://github.com/flutter/engine","homepage":"http://flutter.io","size":126849,"stargazers_count":1716,"watchers_count":1716,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":599,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":599,"open_issues":6,"watchers":1716,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flutter/engine/pulls/6086"},"html":{"href":"https://github.com/flutter/engine/pull/6086"},"issue":{"href":"https://api.github.com/repos/flutter/engine/issues/6086"},"comments":{"href":"https://api.github.com/repos/flutter/engine/issues/6086/comments"},"review_comments":{"href":"https://api.github.com/repos/flutter/engine/pulls/6086/comments"},"review_comment":{"href":"https://api.github.com/repos/flutter/engine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/flutter/engine/pulls/6086/commits"},"statuses":{"href":"https://api.github.com/repos/flutter/engine/statuses/7eb8fa8a428780eeb71b7e16e5858aee26afebe3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mravn-google"}}