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

Fixing release and obfuscated build issues for flutter 3.x.x #118

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

srmncnk
Copy link

@srmncnk srmncnk commented Sep 6, 2022

This PR fixes release and obfuscation issues that were happending since flutter 2.8.x.

Please note that also example package was modified in order to promote the usage of

@pragma('vm:entry-point')

for every top level or static method in order to avoid obfuscation.

Library also failed to send List<Capability?> arguments through ports, likely because class names could not be resolved internally by dart engine. And since only basic types should be sent trough ports, List suits and works instead as well.

Please review and merge this ASAP as a lot of projects depend on this.

@acoutts
Copy link

acoutts commented Sep 6, 2022

Note: I've had the same bug on iOS since upgrading to Flutter 3.3.0:

default	13:10:44.755017+0100	Runner	[VERBOSE-2:shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_isolate/flutter_isolate.dart' not found.
default	13:10:44.755047+0100	Runner	[VERBOSE-2:dart_isolate.cc(668)] Could not resolve main entrypoint function.
default	13:10:44.755074+0100	Runner	[VERBOSE-2:dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
default	13:10:44.755234+0100	Runner	[VERBOSE-2:runtime_controller.cc(385)] Could not create root isolate.
default	13:10:44.755260+0100	Runner	[VERBOSE-2:shell.cc(604)] Could not launch engine with configuration.

@acoutts
Copy link

acoutts commented Sep 6, 2022

Sadly the issue is not resolved on ios with this PR -- same error printed.

Note: I'm using isolate_handler which uses flutter_isolate under the hood, so I'm now working through how to patch this library to work.

@acoutts
Copy link

acoutts commented Sep 6, 2022

Update: my issue of it not appearing to work is because even though I did a dependency override for flutter_isolate in the isolate_handler package to use your PR, my app which consumes isolate_handler still had the pub version of flutter_isolate in the lock file.

I added the dependency override for flutter_isolate to my app pubspec as well, and just had to decorate the function sent to isolate_handler (which then sends it to flutter_isolate), and it's now working.

@srmncnk
Copy link
Author

srmncnk commented Sep 7, 2022

Yes, decorations are mandatory.

Additional note: sending simple classes (containing basic types) through ports does not work anymore, it actually crashes the app, so serialization / deserialization with Map is needed.

@nmfisher
Copy link
Collaborator

Thanks @srmanc

@deadsoul44
Copy link

This is merged but there is no release. Could you please publish a new version on pub.dev?

@etozzato
Copy link

etozzato commented Sep 29, 2022

hello everyone!

For those that are using both flutter_isolate and isolate_handler, this is the fix to the problem until the package becomes available on pub.dev:

(A) Install the latest version of the plugins locally

cd YOUR_APP/plugins
git clone https://github.com/rmawatson/flutter_isolate.git
git clone https://github.com/deakjahn/isolate_handler.git

(B) Update pubspec.yaml to reflect this terrible hack

dependencies:
  flutter:
    sdk: flutter
  ...
  flutter_isolate:
    path: plugins/flutter_isolate
  isolate_handler:
    path: plugins/isolate_handler

(C) Update isolate_handler's pubspec.yaml to reflect this terrible hack

dependencies:
  flutter:
    sdk: flutter
  ...
  flutter_isolate:
    path: ../flutter_isolate

p.s. don't forget to add @pragma('vm:entry-point') to your top-level methods

I tested this on IOS and Android and the errors are gone - for now.

@srmncnk
Copy link
Author

srmncnk commented Sep 30, 2022

@nmfisher Can we do a release on pub.dev?

@nmfisher
Copy link
Collaborator

nmfisher commented Sep 30, 2022 via email

@@ -5,6 +5,7 @@ import 'package:flutter_isolate/flutter_isolate.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter_downloader/flutter_downloader.dart';

@pragma('vm:entry-point')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmfisher also please add that this @pragma('vm:entry-point') is needed to the changelog

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@nmfisher
Copy link
Collaborator

nmfisher commented Oct 2, 2022

v2.0.3 now available on pub.dev:

https://pub.dev/packages/flutter_isolate/versions/2.0.3

@srmncnk
Copy link
Author

srmncnk commented Oct 3, 2022

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants