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

error: native function 'Window_setNeedsReportTimings' (2 arguments) cannot be found #55291

Closed
tony123S opened this issue Apr 21, 2020 · 7 comments

Comments

@tony123S
Copy link

tony123S commented Apr 21, 2020

We calling isolate function from repo class, but failed.

main


void main() {
  // WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

void create(Arguments obj) async {
  WidgetsFlutterBinding.ensureInitialized();

  try {

    var request = http.MultipartRequest(
        "POST",
        Uri.parse(
            "xxxx"));
    request.fields['xxx'] =
        xxxx;

    var streamedResponse = await request.send();
    var response = await http.Response.fromStream(streamedResponse);
             .....

  } catch (e) {
    print(e.toString());
  }
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        providers: globalProviders,
        child: MaterialApp(
          debugShowCheckedModeBanner: false,
          title: 'xxx',
          theme: ThemeData(
            accentIconTheme: const IconThemeData.fallback().copyWith(
              color: Colors.white,
            ),
            primaryTextTheme: TextTheme(title: TextStyle(color: Colors.white)),
            primarySwatch: Colors.orange,
            primaryIconTheme: const IconThemeData.fallback().copyWith(
              color: Colors.white,
            ),
          ),
          localizationsDelegates: [
            const LocalizationDelegate(),
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate
          ],
          supportedLocales: [
            const Locale('en', ''),
            const Locale('zh', ''),
          ],
          onGenerateRoute: Router.generateRoute,
          initialRoute: SplashScreen.ROUTE,
        ));
  }
}

repo

WidgetsFlutterBinding.ensureInitialized();
Isolate isolate = await Isolate.spawn(
    create, Arguments(ac, imageList));

return true;

Error

  E/flutter ( 5395): [ERROR:flutter/runtime/dart_isolate.cc(915)] Unhandled exception:
E/flutter ( 5395): error: native function 'Window_setNeedsReportTimings' (2 arguments) cannot be found
E/flutter ( 5395): #0      Window.onReportTimings=  (dart:ui/window.dart:962:7)
E/flutter ( 5395): #1      SchedulerBinding.addTimingsCallback 
package:flutter/…/scheduler/binding.dart:230
E/flutter ( 5395): #2      SchedulerBinding.initInstances 
package:flutter/…/scheduler/binding.dart:206
E/flutter ( 5395): #3      PaintingBinding.initInstances 
package:flutter/…/painting/binding.dart:21
E/flutter ( 5395): #4      SemanticsBinding.initInstances 
package:flutter/…/semantics/binding.dart:22
E/flutter ( 5395): #5      RendererBinding.initInstances 
package:flutter/…/rendering/binding.dart:29
E/flutter ( 5395): #6      WidgetsBinding.initInstances 
package:flutter/…/widgets/binding.dart:253
E/flutter ( 5395): #7      new BindingBase 
package:flutter/…/foundation/binding.dart:56
E/flutter ( 5395): #8      new _WidgetsFlutterBinding&BindingBase&GestureBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #9      new _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #10     new _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #11     new _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #12     new _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #13     new _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #14     new _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #15     new WidgetsFlutterBinding (package:flutter/src/widgets/binding.dart)
E/flutter ( 5395): #16     WidgetsFlutterBinding.ensureInitialized 
package:flutter/…/widgets/binding.dart:1083
E/flutter ( 5395): #17     create
package:xxx/main.dart:24
E/flutter ( 5395): #18     _AsyncAwaitCompleter.start  (dart:async-patch/async_patch.dart:45:6)
E/flutter ( 5395): #19     create
package:xxx/main.dart:23
E/flutter ( 5395): #20     _startIsolate.<anonymous closure>  (dart:isolate-patch/isolate_patch.dart:310:17)
E/flutter ( 5395): #21     _RawReceivePortImpl._handleMessage  (dart:isolate-patch/iso
@jason-simmons
Copy link
Member

The dart:ui package is only available in the main isolate. Secondary isolates can not use Flutter framework APIs such as WidgetsFlutterBinding.ensureInitialized that rely on dart:ui.

@TahaTesser
Copy link
Member

Hi @tony123S
Does the proposed solution solve the issue?
Thank you

@TahaTesser TahaTesser added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 22, 2020
@tony123S
Copy link
Author

Ya. Thanks

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 23, 2020
@teaphy
Copy link

teaphy commented Jun 8, 2020

How did you handle this exception? I also encountered。

@teaphy
Copy link

teaphy commented Jun 8, 2020

@tony123S Hello tony, can you tell me how to resolve it? Thanks!

@tony123S
Copy link
Author

tony123S commented Jun 8, 2020

@teaphy I not using isolate in my project at the end.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants