Skip to content

[iOS 17] Switching between Chinese and English input on the keyboard freezes #134716

@zhangyanzhu88

Description

@zhangyanzhu88

Is there an existing issue for this?

Steps to reproduce

flutter版本:3.13.4
iOS版本:ios17 Developer Beta

the steps:
Step 1 Switch the Chinese keyboard and click the keyboard "I".
Step 2 Switch the English keyboard and enter the character "'" and enter the character "m".
Step 3 Enter the character "."
Then it gets stuck, then it crashes, then it goes back.

Expected results

Normal input "i'm."

Actual results

The process is stuck and crashed

Code sample

Sample code
import 'dart:convert';
import 'dart:core';

import 'package:flutter/material.dart';
// import 'package:lottie/lottie.dart';
// import 'package:shared_preferences/shared_preferences.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  String _mess = '';
  Map<String, dynamic>? jj;
  // late final SharedPreferences _pers ;
  String mData = '{"main_car_series":0,"birthday":931968000,"s_id":0,"real_person":1,"gender":2,"nick_name":"111","cash":1302.62,"flags":"1,2,5","id":27,"head":482,"tencent_appid":14006193}';

  late TextEditingController _txtCtr;
  late FocusNode _focus;

  @override
  void initState() {
    super.initState();
    _txtCtr = TextEditingController();
    _focus = FocusNode();
    _initData();
  }

  _initData() async {
    // _pers = await SharedPreferences.getInstance();
   
    // jj = mess;
    _mess = jj == null? "null" : jj!['s_id'].toString();

    // List<String> dd = bb.split(':');
    // if(dd.length > 1){
    //    _counter = int.parse(dd[1]);
    // }
   
    setState(() {
      
    });
  }


  // Map<String, dynamic>? get mess{
  //   String? str;
  //   str = _pers.getString("MESS_DATA");
  //   Map<String, dynamic>? json;
  //   if(str == null || str.isEmpty){
  //     str = mData;
  //   }
  //   json = jsonDecode(str);
  //   // ignore: avoid_print
  //   print('messdata====='+str);
  //   return json;
  // }

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
      _focus.unfocus();
      _mess = '计数:'+_counter.toString();
      jj!['s_id'] = _counter;
      // _pers.setString("MESS_DATA", _mess).then((p){
      //   // ignore: avoid_print
      //   print('add====='+mess!);
      // });
      // saveData();
    });
  }

  // Future<void> saveData() async {
  //   await _pers.setString("MESS_DATA", jsonEncode(jj));
  // }
  // Future<void> removeData() async {
  //   await _pers.remove("MESS_DATA");
  // }

  void clearData(){
    // _pers.remove("MESS_DATA").then((p){
      
    // });
    // removeData();
    // setState(() {
      
    // });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have clicked hhhh the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            Text(
              _mess,
              style: Theme.of(context).textTheme.headline4,
            ),
            FloatingActionButton(
              onPressed: _incrementCounter, 
              child: const Icon(Icons.add),
            ),
            // Lottie.asset("assets/pot.json",width: 500,height: 500,repeat: true),
            TextField(controller: _txtCtr,onTap: () {
              // // _focus.requestFocus();
              // await Future.delayed(const Duration(milliseconds: 500));
              // _focus.unfocus();
              // Future.delayed(const Duration(milliseconds: 1000),(){
              //   _focus.unfocus();
              // });
              // Future.delayed(const Duration(milliseconds: 1000),(){
              //   _focus.requestFocus();
              // });
              // if(_txtCtr.text.isEmpty){
              //   _txtCtr.text = "1";
              // }
              // if(_txtCtr.text == "1"){
              //   _txtCtr.text = '';
              // }
            },onChanged: (value) {
              // if(_txtCtr.text.isEmpty){
              //   _txtCtr.text = "m";
              // }
              _mess = _txtCtr.text;
              setState(() {
                
              });
            },focusNode: _focus,),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: clearData,
        tooltip: 'Increment',
        child: const Icon(Icons.remove),
      ), // This trailing comma makes auto-formatting nicer for build methods.
      
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Uploading 1694679470.mp4…

Logs

Logs
[Paste your logs here]

Flutter Doctor output

The app “Runner” has been killed by the operating system because it is using too much memory.
Domain: IDEDebugSessionErrorDomain
Code: 11
Recovery Suggestion: Use a memory profiling tool to track the process memory usage.
User Info: {
    DVTErrorCreationDateKey = "2023-09-14 07:57:40 +0000";
    IDERunOperationFailingWorker = DBGLLDBLauncher;
}
--

Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : {
    "device_isCoreDevice" = 1;
    "device_model" = "iPhone14,2";
    "device_osBuild" = "17.0 (21A329)";
    "device_platform" = "com.apple.platform.iphoneos";
    "dvt_coredevice_version" = "348.1";
    "dvt_mobiledevice_version" = "1643.2.4";
    "launchSession_schemeCommand" = Run;
    "launchSession_state" = 2;
    "launchSession_targetArch" = arm64;
    "operation_duration_ms" = 180352;
    "operation_errorCode" = 11;
    "operation_errorDomain" = IDEDebugSessionErrorDomain;
    "operation_errorWorker" = DBGLLDBLauncher;
    "operation_name" = IDERunOperationWorkerGroup;
    "param_debugger_attachToExtensions" = 0;
    "param_debugger_attachToXPC" = 1;
    "param_debugger_type" = 3;
    "param_destination_isProxy" = 0;
    "param_destination_platform" = "com.apple.platform.iphoneos";
    "param_diag_MainThreadChecker_stopOnIssue" = 0;
    "param_diag_MallocStackLogging_enableDuringAttach" = 0;
    "param_diag_MallocStackLogging_enableForXPC" = 1;
    "param_diag_allowLocationSimulation" = 1;
    "param_diag_checker_tpc_enable" = 1;
    "param_diag_gpu_frameCapture_enable" = 0;
    "param_diag_gpu_shaderValidation_enable" = 0;
    "param_diag_gpu_validation_enable" = 0;
    "param_diag_memoryGraphOnResourceException" = 0;
    "param_diag_queueDebugging_enable" = 1;
    "param_diag_runtimeProfile_generate" = 0;
    "param_diag_sanitizer_asan_enable" = 0;
    "param_diag_sanitizer_tsan_enable" = 0;
    "param_diag_sanitizer_tsan_stopOnIssue" = 0;
    "param_diag_sanitizer_ubsan_stopOnIssue" = 0;
    "param_diag_showNonLocalizedStrings" = 0;
    "param_diag_viewDebugging_enabled" = 1;
    "param_diag_viewDebugging_insertDylibOnLaunch" = 1;
    "param_install_style" = 0;
    "param_launcher_UID" = 2;
    "param_launcher_allowDeviceSensorReplayData" = 0;
    "param_launcher_kind" = 0;
    "param_launcher_style" = 99;
    "param_launcher_substyle" = 8192;
    "param_runnable_appExtensionHostRunMode" = 0;
    "param_runnable_productType" = "com.apple.product-type.application";
    "param_structuredConsoleMode" = 1;
    "param_testing_launchedForTesting" = 0;
    "param_testing_suppressSimulatorApp" = 0;
    "param_testing_usingCLI" = 0;
    "sdk_canonicalName" = "iphoneos17.0";
    "sdk_osVersion" = "17.0";
    "sdk_variant" = iphoneos;
}
--

System Information

macOS Version 13.5.2 (Build 22G91)
Xcode 15.0 (22265) (Build 15A240d)
Timestamp: 2023-09-14T15:57:40+08:00

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemse: OS-version specificAffects only some versions of the relevant operating systemfound in release: 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions