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

[iOS] Permission dialog when pasting text from universal clipboard may be closed before user has had time to allow pasting #121446

Open
HaloWang opened this issue Feb 25, 2023 · 5 comments
Labels
a: fidelity Matching the OEM platforms better a: text input Entering text in a text field or keyboard related problems found in release: 3.7 Found to occur in 3.7 found in release: 3.8 Found to occur in 3.8 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@HaloWang
Copy link

Steps to Reproduce

  1. flutter create handoff_clipboard
  2. prepare a macbook and any iOS deivce
  3. make sure Apple's 'Handoff' feature is enabled on the devices above.
  4. add a TextField() at somewhere of the lib/main.dart
  5. run flutter on the ios device
  6. cmd+c some text on the screen of macOS
  7. tap TextField widget on the screen of iOS
  8. tap "Paste"
  9. There flash an alert and then disappear, leave a Error in console (Xcode/vscode): [Pasteboard] ...requesting item failed with error: Error Domain=PBErrorDomain Code=13 "Operation not authorized." UserInfo={NSLocalizedDescription=Operation not authorized.}
  10. tap paste again, the alert will stay on the screen, looks good.

some codes in starter project, if useful

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          // 🚧 add this line
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            // 🚧 add this line
            TextField(),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }

flutter doctor

➜  ~ flutter doctor          
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale en-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.75.1)
[✓] Proxy Configuration
[✓] Connected device (3 available)
[✓] HTTP Host Availability
@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label Feb 27, 2023
@danagbemava-nc danagbemava-nc changed the title Pasting text from macbook to iOS/iPadOS device using Apple's Handoff feature looks buggy [iOS] Pasting text using Apple's Handoff is buggy Feb 27, 2023
@danagbemava-nc danagbemava-nc changed the title [iOS] Pasting text using Apple's Handoff is buggy [iOS] Permission dialog when pasting text using Apple's Handoff may be closed before user has had time to allow pasting Feb 27, 2023
@danagbemava-nc
Copy link
Member

danagbemava-nc commented Feb 27, 2023

Issue is reproducible on the latest versions of flutter.

The bug didn't reproduce for me when I was just copy/pasting text on the iPhone but when handoff entered the picture, the bug reproduced.

Pasting from Mac Pasting from iPad
RPReplay_Final1677490522.MP4
RPReplay_Final1677491473.MP4

Related: #103163

This did not reproduce on macOS

code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: const Center(
        child: TextField(),
      ),
    );
  }
}
logs
Launching lib/main.dart on Nexus in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: X8NNQ9CYL2
Xcode build done.                                           20.2s
(lldb) 2023-02-27 09:50:19.805448+0000 Runner[10557:2212630] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
[SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
Connecting to VM Service at ws://127.0.0.1:50017/VBYbgachHuY=/ws
Successfully load keyboard extensions
[SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
[Pasteboard] ...requesting item failed with error: Error Domain=PBErrorDomain Code=13 "Operation not authorized." UserInfo={NSLocalizedDescription=Operation not authorized.}
Application finished.
Exited
flutter doctor -v
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale en-GB)
    • Flutter version 3.7.5 on channel stable at /Users/nexus/dev/sdks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c07f788888 (4 days ago), 2023-02-22 17:52:33 -0600
    • Engine revision 0f359063c4
    • Dart version 2.19.2
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[!] Android Studio (version 2022.1)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.75.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.58.0

[✓] Connected device (5 available)
    • M2007J20CG (mobile)    • adb-5dd3be00-17AYzd._adb-tls-connect._tcp. • android-arm64  • Android 12 (API 31)
    • Nexus (mobile)         • 00008020-001875E83A38002E                  • ios            • iOS 16.3.1 20D67
    • iPhone 14 Pro (mobile) • 7256EA18-F2CB-4F96-9398-80DC7756A275       • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)        • macos                                      • darwin-arm64   • macOS 13.2.1 22D68 darwin-arm64
    • Chrome (web)           • chrome                                     • web-javascript • Google Chrome 110.0.5481.100
    ! Error: Dean’s iPad is busy: Waiting to connect and unlock the device. Xcode will continue when Dean’s iPad is finished. (code -10)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.
[!] Flutter (Channel master, 3.8.0-16.0.pre.57, on macOS 13.2.1 22D68 darwin-arm64, locale en-GB)
    • Flutter version 3.8.0-16.0.pre.57 on channel master at /Users/nexus/dev/sdks/flutters
    ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 45723adf4d (5 hours ago), 2023-02-26 23:35:37 -0500
    • Engine revision 88b48c357b
    • Dart version 3.0.0 (build 3.0.0-275.0.dev)
    • DevTools version 2.22.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] Android Studio (version 2022.1)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.75.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.58.0

[✓] Connected device (7 available)
    • M2007J20CG (mobile)    • adb-5dd3be00-17AYzd._adb-tls-connect._tcp. • android-arm64  • Android 12 (API 31)
    • Dean’s iPad (mobile)   • 00008103-000825C811E3401E                  • ios            • iOS 16.3.1 20D67
    • Nexus (mobile)         • 00008020-001875E83A38002E                  • ios            • iOS 16.3.1 20D67
    • iPhone 14 Pro (mobile) • 7256EA18-F2CB-4F96-9398-80DC7756A275       • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)        • macos                                      • darwin-arm64   • macOS 13.2.1 22D68 darwin-arm64
    • Web Server (web)       • web-server                                 • web-javascript • Flutter Tools
    • Chrome (web)           • chrome                                     • web-javascript • Google Chrome 110.0.5481.100
    ! Error: Dean’s iPad is busy: Waiting to connect and unlock the device. Xcode will continue when Dean’s iPad is finished. (code -10)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

@danagbemava-nc danagbemava-nc added a: text input Entering text in a text field or keyboard related problems platform-ios iOS applications specifically engine flutter/engine repository. See also e: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.7 Found to occur in 3.7 found in release: 3.8 Found to occur in 3.8 and removed in triage Presently being triaged by the triage team labels Feb 27, 2023
@danagbemava-nc danagbemava-nc changed the title [iOS] Permission dialog when pasting text using Apple's Handoff may be closed before user has had time to allow pasting [iOS] Permission dialog when pasting text from universal clipboard may be closed before user has had time to allow pasting Feb 27, 2023
@chinmaygarde chinmaygarde removed the engine flutter/engine repository. See also e: labels. label Feb 27, 2023
@justinmc
Copy link
Contributor

justinmc commented Mar 9, 2023

CC @jmagman Do we expect Handoff to work with Flutter right now? I haven't ever tried it.

@jamescardona11
Copy link

I can reproduce the issue in Flutter 3.10.3 • channel stable

@flutter-triage-bot flutter-triage-bot bot added team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Jul 8, 2023
@alexandr-efimov
Copy link

alexandr-efimov commented Jul 9, 2023

Same, regularly reproduced. Added a button to fill form, in half cases request to user permission closed almost imediately.

`

          onPressed: () async {
            final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
            String? clipboardText = clipboardData?.text;
            if (clipboardText != null) {
              setState(() {
                _formKey.currentState!.fields['webUrl']?.didChange(clipboardText);
              });
            }
          },

`

doctor:
`
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F82 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)

`

@stuartmorgan stuartmorgan added the P2 Important issues not at the top of the work list label Jul 31, 2023
@stuartmorgan
Copy link
Contributor

/cc @hellohuanlin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: fidelity Matching the OEM platforms better a: text input Entering text in a text field or keyboard related problems found in release: 3.7 Found to occur in 3.7 found in release: 3.8 Found to occur in 3.8 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests

8 participants