-
Notifications
You must be signed in to change notification settings - Fork 28.5k
[platform_view]Send platform message when platform view is focused #105050
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
[platform_view]Send platform message when platform view is focused #105050
Conversation
849fcd0
to
37eba75
Compare
It was rolled into the framework a few days ago #104885 |
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.
I think including integration tests in the same PR is a good idea, while it's fresh how this works.
Code LGTM.
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.
LGTM % nits
Sorry have one question, see: #105050 (comment)
@@ -660,7 +660,16 @@ class _UiKitViewState extends State<UiKitView> { | |||
} | |||
|
|||
void _onFocusChange(bool isFocused) { | |||
// TODO(hellohuanlin): send 'TextInput.setPlatformViewClient' channel message to engine after the engine is updated to handle this message. | |||
if (!isFocused) { |
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.
nits:
Maybe this would be more readable if we check if (isFocused) first?
if (isFocused) {
SystemChannels.textInput.invokeMethod<void>(
'TextInput.setPlatformViewClient',
<String, dynamic>{'platformViewId': _controller!.id},
}
Or we can escape early instead of if-else
if (!isfocused) {
return;
}
SystemChannels.textInput.invokeMethod<void>(
'TextInput.setPlatformViewClient',
<String, dynamic>{'platformViewId': _controller!.id},
} else { | ||
SystemChannels.textInput.invokeMethod<void>( | ||
'TextInput.setPlatformViewClient', | ||
<String, dynamic>{'platformViewId': _controller!.id}, |
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.
How do we ensure _controller!
will not crash?
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.
Oh because _controller
and _focusNode
are set together:
setState(() {
_controller = controller;
_focusNode = FocusNode(debugLabel: 'UiKitView(id: $id)');
});
And this _onFocusChange
function is triggered by the _focusNode
, which must be present, so _controller
must also be present.
As discussed since we can't trigger a tap on platform view from the framework integration test (more details here) |
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.
This LGTM, up to you whether you want to write the integration test in this PR or another, if you can get the native testing working.
Since it's not stamped yet, I will add integration test to this PR. |
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.
ios_platform_view_xcuitests
isn't a good name, what if we wanted to add macOS or non-xcuitests to it?
Is there any reason not to add the tests to ios_platform_view_tests
and reuse that project? There's so much boilerplate for every new project we add...
GitHub doesn't let us comment on binaries, but we shouldn't check in any of the app icons.
Also the analyzer isn't happy:
dev/integration_tests/ios_platform_view_xcuitests/ios/RunnerUITests/RunnerUITests.m:50: trailing blank line
@@ -0,0 +1,44 @@ | |||
# Miscellaneous |
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.
It's inconsistent but I think we generally don't check in gitignores for projects in this repo since there's already a top-level gitignore. See if anything unexpected gets tracked if you remove this.
@@ -0,0 +1,49 @@ | |||
// Copyright 2014 The Flutter Authors. All rights reserved. |
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.
native_ui_platform_view_tests_ios
to better match native_ui_tests_macos
?
You'll need to add an entry to .ci.yaml
to get this to run anywhere:
- name: Mac_ios native_ui_platform_view_tests_ios
bringup: true
recipe: devicelab/devicelab_drone
presubmit: false
timeout: 60
properties:
tags: >
["devicelab", "ios", "mac"]
task_name: native_ui_platform_view_tests_ios
scheduler: luci
buildSettings = { | ||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||
DEVELOPMENT_TEAM = S8QB4VV633; |
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.
Remove the Flutter team.
buildSettings = { | ||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||
DEVELOPMENT_TEAM = S8QB4VV633; |
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.
Remove
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.
Changes for the integration test
@jmagman The existing I can look into if there's a way to host 2 Apps in the same project (maybe that's what a "flavor" can do?) |
Oh sorry I see your comment about this from above. What if you used dart defines? Does this work? await flutter(
'build',
options: <String>[
'ios',
'-v',
'--release',
'--dart-define',
'SKIP_DRIVER_EXTENSION=true',
'--config-only',
],
); void main() {
if (!bool.fromEnvironment('SKIP_DRIVER_EXTENSION')) {
enableFlutterDriverExtension();
}
runApp(const MyApp());
} |
Or avoiding double negatives: await flutter(
'build',
options: <String>[
'ios',
'-v',
'--release',
'--dart-define',
'ENABLE_DRIVER_EXTENSION=false',
'--config-only',
],
); void main() {
if (bool.fromEnvironment('ENABLE_DRIVER_EXTENSION'), defaultValue: true) {
enableFlutterDriverExtension();
}
runApp(const MyApp());
} |
68758f9
to
79b49e6
Compare
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.
Please add an ownership for this test here: https://github.com/flutter/flutter/blob/master/TESTOWNERS#L139
81596d5
to
1682d5e
Compare
@@ -195,7 +195,7 @@ | |||
/dev/devicelab/bin/tasks/module_custom_host_app_name_test.dart @zanderso @flutter/tool | |||
/dev/devicelab/bin/tasks/module_host_with_custom_build_test.dart @zanderso @flutter/tool | |||
/dev/devicelab/bin/tasks/module_test.dart @zanderso @flutter/tool | |||
/dev/devicelab/bin/tasks/native_ui_tests_ios.dart @jmagman @flutter/engine |
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.
.ci.yaml
Outdated
presubmit: false | ||
timeout: 60 | ||
properties: | ||
tags: > | ||
["devicelab", "ios", "mac"] |
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.
I led you astray, this isn't a devicelab test, which means it has a tethered iOS device, it should be "hostonly" since it only runs in the simulator.
presubmit: false | |
timeout: 60 | |
properties: | |
tags: > | |
["devicelab", "ios", "mac"] | |
timeout: 60 | |
properties: | |
tags: > | |
["devicelab", "hostonly"] |
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.
do you mean ["hostonly", "ios", "mac"]
?
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.
No, I don't think so, I think that will make it require a machine with a tethered iOS device.
Like this:
Line 2394 in 712860d
["devicelab", "hostonly"] |
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.
If this is a host only test, the target name should be updated as Mac native_platform_view_ui_tests_ios
, which controls what test bed to run.
The tags here should also be updated as ["devicelab", "hostonly"]
as @jmagman suggested. Though this doesn't control the test bed, it affects performance metrics tags and build stats in bigquery. It would be good to reflect the truth of the test.
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.
Thanks @keyonghan!
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.
Interesting, I don't think any of the functionalities require code signing. (@cyanglaz to confirm).
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.
This is the device lab testing so I guess it will require code signing for the app to run on devices, but if you just want to test the functionalities on simulator you can bypass code signing.
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.
I think the Mac
name before the test name indicates that it is to be tested on the simulator? @keyonghan is it correct?
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.
Here the devicelab
means tasks located under dev/devicelab/bin/tasks
, which all share the same devicelab_drone
recipes. It includes two types: the ones that need a devicelab testbed (which needs a physical phone connected), the other ones that run on a host only bot.
The Mac
name will route all tests to the second type, whereas the Mac_ios
will route tests to the first type.
The test added in this PR does run on a host only bot. You may want to take a look at the log to see if any findings: https://logs.chromium.org/logs/flutter/led/keyonghan_google.com/943f3399cb63bc7e1dc12ccdfcf310d85888f7de9f910789f46af2ed8a9f93cf/+/u/run_native_platform_view_ui_tests_ios/test_stdout
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.
From the bottom of this link, it looks like the error is in Android:
Task result:
{
"success": false,
"reason": "Task failed: DeviceException: The ANDROID_SDK_ROOT environment variable is missing. The variable must point to the Android SDK directory containing platform-tools."
}
It also mention about code signing tho, but not part of the failure reason.
deviceOperatingSystem = DeviceOperatingSystem.ios; | ||
|
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.
And since this is "hostonly" and doesn't need a tethered device, you should be able to delete this line.
deviceOperatingSystem = DeviceOperatingSystem.ios; |
dev/integration_tests/ios_platform_view_tests/ios/PlatformViewUITests/PlatformViewUITests.m
Show resolved
Hide resolved
@@ -54,6 +73,13 @@ | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
E09898E32853E9F000064317 /* Frameworks */ = { |
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.
Was this empty frameworks build phase added accidentally? If Xcode did it automatically it's fine.
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.
it's automatically added by Xcode when I add the test target.
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.
LGTM
Re: the test failures, rebase past #105927 |
9fd6451
to
fa67e7c
Compare
be0e5e1
to
d7667a4
Compare
This PR actually sends message channel to the engine to tell the TextInputPlugin that a platform view is focused.
This PR should wait till the engine roll is done (engine PR here)
We probably want to add integration test too. I am looking into how it's done now.
List which issues are fixed by this PR. You must list at least one issue.
#34187
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.