devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Add a fallback for detecting whether an app is a flutter app in profile mode

Open dheerajverma009 opened this issue 2 years ago • 12 comments

image_1

When running in Debug mode. Devtools>>performance tab look this.

image_2

When running in Profile mode or in release mode. Devtools>>performance tab look this.

Isn't Flutter frames button, bar graph and other missing options should also visible for profile and release mode?

dheerajverma009 avatar Jan 18 '24 14:01 dheerajverma009

Any update??

dheerajverma009 avatar Feb 10 '24 04:02 dheerajverma009

Do you have a consistent repro for this? I haven't been able to reproduce.

kenzieschmoll avatar Feb 13 '24 23:02 kenzieschmoll

@kenzieschmoll can't share you the repo in which the issue is coming. But i tried it with other repos by creating new ones, but works as expected. Not sure what is issue related to.

dheerajverma009 avatar Feb 14 '24 11:02 dheerajverma009

@dheerajverma009 please provide a repro case if you can, otherwise this issue will automatically close. Thanks.

kenzieschmoll avatar Feb 14 '24 16:02 kenzieschmoll

@kenzieschmoll Looks like it is specific to my project. I tried creating other projects with same version but seems they are showing frame graph as expected. Can you give some suggestion what could be wrong.

dheerajverma009 avatar Feb 23 '24 11:02 dheerajverma009

It appears that your app is not being detected as a Flutter app in profile mode. We are looking for the presence of a specific library in your application: https://github.com/flutter/devtools/blob/master/packages/devtools_app_shared/lib/src/service/connected_app.dart/#L16.

This should be available for a standard flutter app. Is there something about your app that would make this library not present in profile mode?

kenzieschmoll avatar Feb 23 '24 18:02 kenzieschmoll

@kenzieschmoll

After debugging, I found that extra-gen-snapshot-options=--obfuscate inside gradle.properties was responsible for above scenario.

I don't know why it was causing the frame graph to not appear.

dheerajverma009 avatar Feb 27 '24 07:02 dheerajverma009

@bkonyi @dnfield do you know why extra-gen-snapshot-options=--obfuscate would cause this?

kenzieschmoll avatar Feb 29 '24 02:02 kenzieschmoll

From https://github.com/dart-lang/sdk/issues/30524:

At the end of precompilation we also collect and rename scripts, libraries and Symbol instances. Libraries and scripts URI are also renamed.

If you're relying on a particular library being present and looking for it by name, you won't be able to find it since it'll have been obfuscated.

bkonyi avatar Feb 29 '24 17:02 bkonyi

If you're relying on a particular library being present and looking for it by name, you won't be able to find it since it'll have been obfuscated.

Will this only be the case in profile mode? It appears that debug mode worked fine for this user.

kenzieschmoll avatar Feb 29 '24 17:02 kenzieschmoll

Probably since debug mode uses the JIT and --obfuscate is only used when generating AOT snapshots with gen_snapshot (as far as I know).

bkonyi avatar Feb 29 '24 17:02 bkonyi

Got it. We can fix this by adding a fallback check in profile mode. One idea is to check that an arbitrary Flutter service extension is available for the connected app, though we may have some race / timing issues with performing this check at the time that we initialize the connected app.

kenzieschmoll avatar Feb 29 '24 18:02 kenzieschmoll