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

dart_plugin_registrant.dart + AOT + --obfuscation #137972

Closed
2 tasks done
jwinarske opened this issue Nov 6, 2023 · 12 comments
Closed
2 tasks done

dart_plugin_registrant.dart + AOT + --obfuscation #137972

jwinarske opened this issue Nov 6, 2023 · 12 comments
Labels
customer: going P1 High-priority issues at the top of the work list waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds will need additional triage This issue or PR needs attention during weekly triage

Comments

@jwinarske
Copy link

Is there an existing issue for this?

Steps to reproduce

Manually build AOT components where you can control use of the --obfuscate flag.

Build sequences:
https://github.com/meta-flutter/meta-flutter/blob/kirkstone/conf/include/flutter-app.inc#L269
https://github.com/meta-flutter/meta-flutter/blob/kirkstone/conf/include/flutter-app.inc#L318-L329

Expected results

correctly register plugins regardless of obfuscate flag

Actual results

without passing --obfuscate to gen_snapshot:

  • Flutter Package examples - correctly register plugins
  • Gallery - does not register plugins
  • Wonderous - does not register plugins

passing --obfuscate to gen_snapshot:

  • Flutter Package examples - correctly register plugins
  • Gallery - correctly register plugins
  • Wonderous - correctly register plugins

Dumping symbols from AOT in both cases using readelf, the expected entry points are present:

working

 11673: 000000000059914c   116 FUNC    LOCAL  DEFAULT    7 _PluginRegistrant.register
 11674: 00000000005991c0    44 FUNC    LOCAL  DEFAULT    7 _PluginRegistrant.register
 11675: 00000000005991ec     8 FUNC    LOCAL  DEFAULT    7 dartPluginRegistrantLibrary
 11676: 00000000005991f4     8 FUNC    LOCAL  DEFAULT    7 dartPluginRegistrantLibrary
 11677: 00000000005991fc    48 FUNC    LOCAL  DEFAULT    7 main

not working

131825: 0000000001e991e0     8 FUNC    LOCAL  DEFAULT    7 dartPluginRegistrantLibrary
131826: 0000000001e991e8     8 FUNC    LOCAL  DEFAULT    7 dartPluginRegistrantLibrary
131827: 0000000001e991f0   320 FUNC    LOCAL  DEFAULT    7 _PluginRegistrant.register
131828: 0000000001e99330    44 FUNC    LOCAL  DEFAULT    7 _PluginRegistrant.register
131829: 0000000001e9935c    96 FUNC    LOCAL  DEFAULT    7 main
131830: 0000000001e993bc    44 FUNC    LOCAL  DEFAULT    7 main

Code sample

NA

Screenshots or Video

NA

Logs

NA

Flutter Doctor output

Doctor output
[!] Flutter (Channel [user-branch], 3.13.9, on Fedora Linux 38 (Workstation Edition) 6.5.8-200.fc38.x86_64, locale en_US.UTF-8)
    ! Flutter version 3.13.9 on channel [user-branch] at /mnt/raid10/workspace-automation/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision d211f42860 (12 days ago), 2023-10-25 13:42:25 -0700
    • Engine revision 0545f8705d
    • Dart version 3.1.5
    • DevTools version 2.25.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Linux toolchain - develop for Linux desktop
    • clang version 16.0.6 (Fedora 16.0.6-3.fc38)
    • cmake version 3.27.7
    • ninja version 1.11.1
    • pkg-config version 1.8.0

[✓] VS Code (version 1.84.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.76.0

[✓] Connected device (2 available)
    • Linux (desktop)            • linux              • linux-x64 • Fedora Linux 38 (Workstation Edition) 6.5.8-200.fc38.x86_64
    • Toyota homescreen (mobile) • desktop-homescreen • linux-x64 • homescreen x86_64

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

! Doctor found issues in 1 category.
List of custom devices in "/mnt/raid10/workspace-automation/.config/flutter/custom_devices.json":
  id: desktop-homescreen, label: Toyota homescreen, enabled: true
[joel@air workspace-automation]$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.13.9, on Fedora Linux 38 (Workstation Edition) 6.5.8-200.fc38.x86_64, locale en_US.UTF-8)
    ! Flutter version 3.13.9 on channel [user-branch] at /mnt/raid10/workspace-automation/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[✓] Linux toolchain - develop for Linux desktop
[✓] VS Code (version 1.84.1)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 1 category.
@jwinarske jwinarske added customer: crowd Affects or could affect many people, though not necessarily a specific customer. and removed customer: crowd Affects or could affect many people, though not necessarily a specific customer. labels Nov 6, 2023
@jwinarske
Copy link
Author

There needs to be a customer: toyota tag

@mraleph
Copy link
Member

mraleph commented Nov 7, 2023

Actual results

Just to confirm: are you saying that if you pass --obfuscate to gen_snapshot then thing work correctly and if you do not pass --obfuscate then things work incorrectly? I am a bit puzzled.

@jwinarske
Copy link
Author

@mraleph

Correct. It's as if in the non-working case it's taking an alternate entry. Non-working cases default to platform channel.

The other pattern I determined is the working cases are all "local" packages. The non-working case use "remote" packages.

Not sure if Android and iOS default to having obfuscation set. If so that might explain why it's now showing up.

There was another issue a while back about obfuscation breaking dart registration I was looking at. Which introduced the --source solution.

@christopherfujino christopherfujino added dependency: dart Dart team may need to help us P1 High-priority issues at the top of the work list labels Nov 7, 2023
@danagbemava-nc danagbemava-nc added the will need additional triage This issue or PR needs attention during weekly triage label Nov 9, 2023
@aam
Copy link
Member

aam commented Nov 13, 2023

@jwinarske , would it be possible for you to make actual repro out of https://github.com/flutter/packages/tree/main/packages/flutter_image/example for example? This should help understand better where in the stack there is obfuscate vs non-obfuscate confusion.

cc'ing @stuartmorgan since it seems to be in plugins/packages realm.

@stuartmorgan
Copy link
Contributor

cc'ing @stuartmorgan since it seems to be in plugins/packages realm.

It is unclear to me what the expected outcome of this issue is given that #103660 and #107762 both explained that what this issue lists under "expected results" is in fact a bug that we intend to fix.

As far as I can tell this is a duplicate of #107762.

@jwinarske
Copy link
Author

@stuartmorgan this is a new issue. Which in everything I've read should not behave this way. There is also another issue that drove the --source option; where dart plugin registrant was ignored only when obfuscated was set. Which indicated this might be a leftover corner case. Cross compiling an AOT by script or manually on a host machine is a valid use case. Dart pluginn registrant (vm entry) works today if I enable obsfucation when dealing with "remote package" definitions. In all cases of "local packages" plug-in references work with or without obfuscation.

@stuartmorgan
Copy link
Contributor

@stuartmorgan this is a new issue

It would be helpful if you could add more detail to the STR then. Right now the STR section is just links to a script that appear to be part of a build process rather than actual steps, so I was trying to extrapolate from that, and it appeared that you were describing a situation where—when building for a third-party embedding—the flutter-tool-generated first-party registrant code is sometimes being run and sometimes not (which in the important respects would be the same as #107762).

@jwinarske
Copy link
Author

@stuartmorgan your referenced case is the difference of dart plugin registrant between debug and AOT. I resolved issue on my side using the --source options (third party tooling).

This case is related to obfuscation and dart plugin registration. Two independent things. The build steps I referenced is one way to reproduce this issue.

Is obfuscation enabled by default for mobile?

@stuartmorgan
Copy link
Contributor

This case is related to obfuscation and dart plugin registration. Two independent things.

I understand that the exact details of what you are saying is different between the case where the registration runs and the case where it doesn't are different. That's why I said it would be the same "in the important respects".

I'm still not clear whether my understanding of the issue described in my last comment is correct or not. Please provide actual steps to reproduce the issue so that it's clear what the scenario is here.

@aam aam removed the dependency: dart Dart team may need to help us label Nov 14, 2023
@aam
Copy link
Member

aam commented Nov 14, 2023

I'm removing dependency: dart label as the issue doesn't seem to concern dart vm.

@Hixie Hixie added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 14, 2023
Copy link

github-actions bot commented Dec 6, 2023

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

@github-actions github-actions bot closed this as completed Dec 6, 2023
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 Dec 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer: going P1 High-priority issues at the top of the work list waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds will need additional triage This issue or PR needs attention during weekly triage
Projects
None yet
Development

No branches or pull requests

8 participants