Giter Club home page Giter Club logo

Comments (10)

swift-kim avatar swift-kim commented on June 19, 2024 1

The implementation of the third solution in flutter-tizen/flutter-tizen#177 (comment) can be found at: swift-kim/flutter-tizen@6fd8233

The commit should land after the next Flutter stable release.

cc @HakkyuKim

from plugins.

swift-kim avatar swift-kim commented on June 19, 2024 1

My conclusion is that plugins are generally not expected to work properly inside isolates. This applies to other platforms as well, regardless of the underlying implementation mechanism (platform channel or Dart plugin registrant). (There's even a third-party package called flutter_isolate that allows invoking plugins from isolates.)

The only workaround is to call the register function of a plugin (Dart plugin) before invoking its API from an isolate.

Example (path_provider_tizen):

import 'package:flutter/foundation.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path_provider_tizen/path_provider_tizen.dart';

compute((Object? message) async {
  PathProviderPlugin.register();
  await getApplicationDocumentsDirectory();
}, null);

from plugins.

bbrto21 avatar bbrto21 commented on June 19, 2024

to solve this limitation, do we need re-implement plugins based on native?

from plugins.

swift-kim avatar swift-kim commented on June 19, 2024

No, we need to check how other platforms tackle this problem but I had not enough time to investigate.

from plugins.

swift-kim avatar swift-kim commented on June 19, 2024
  • I tested path_provider_windows on Windows and it worked without problem on secondary isolates. I'm still not exactly sure how the Dart plugin registry for Windows is different from flutter-tizen's.
  • generated_main.dart was not generated by flutter_tools even with flutter/flutter#79669 applied on Windows. I don't know why.
  • Still flutter/flutter#79669 will land to the stable branch soon and it would be better to re-implement flutter-tizen's Dart plugin registry based on the official one. In fact its approach is not quite different from ours, but the main difference is that generateMainDartWithPluginRegistrant (equivalent of _createEntrypoint for Tizen) is part of the build graph.
  • Consider adding implements: attributes to Tizen plugins' pubspecs. It's not quite necessary tho because the attribute doesn't do very much thing.

from plugins.

swift-kim avatar swift-kim commented on June 19, 2024

I'll test swift-kim/flutter-tizen@1ed4ee7 when the next stable Flutter version is released.

Related engine PR: flutter/engine#25496

from plugins.

HakkyuKim avatar HakkyuKim commented on June 19, 2024

@swift-kim That was really fast! Thank you!
I'll have a closer look tomorrow.

from plugins.

swift-kim avatar swift-kim commented on June 19, 2024

It seems Dart plugin registrants are not yet fully implemented for secondary isolates in the upstream engine: flutter/flutter#81421

Thus the change in #123 (comment) has no effect.

from plugins.

swift-kim avatar swift-kim commented on June 19, 2024

I tried invoking InvokeDartPluginRegistrantIfAvailable (Dart_RootLibrary~Dart_Invoke) after initializing secondary isolates but encountered only some segmentation faults. I'm not sure where I can safely put the code (I tried in DartIsolateInitializeCallback and SpawnIsolateTask:Run).

from plugins.

swift-kim avatar swift-kim commented on June 19, 2024

Will be fixed by flutter-tizen/flutter-tizen#516.

from plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.