Skip to content

Conversation

@polina-c
Copy link
Contributor

No description provided.

@polina-c polina-c requested a review from a team as a code owner November 22, 2022 17:40
@polina-c polina-c requested review from CoderDake and removed request for a team November 22, 2022 17:40
/// ]
const bool _kEnableExperiments = bool.fromEnvironment('enable_experiments');

@visibleForTesting
Copy link
Contributor

Choose a reason for hiding this comment

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

since this isn't hidden is visibleForTesting necessary here?

Copy link
Contributor Author

@polina-c polina-c Nov 23, 2022

Choose a reason for hiding this comment

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

visibleForTesting protects public members from use in non-test environment: https://api.flutter.dev/flutter/meta/visibleForTesting-constant.html

It cannot make private methods public.

@polina-c polina-c changed the title Add comment about feature flags. Make feature flags more readable/supportable. Nov 23, 2022
const bool _kEnableExperiments = bool.fromEnvironment('enable_experiments');

@visibleForTesting
bool enableExperiments = _kEnableExperiments;
Copy link
Member

Choose a reason for hiding this comment

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

why can't we just do this:
final bool enableExperiments = _kEnableExperiments || !kReleaseMode;

Then we don't need a method setExperimentsEnabled at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is for protection.

enableExperiments is private and protected from switching back and force.
It can be flipped only once to true.

Copy link
Member

Choose a reason for hiding this comment

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

we don't need it to be switched at all though. We don't need to enable experiments from main.dart, we can just set the value from the start in feature_flags.dart. The following code would still allow us to disable experiments for tests if that is a concern:

@visibleForTesting
bool enableExperiments = _kEnableExperiments || !kReleaseMode;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can we disable experiments for all tests? As I know there is no method like 'setupForAllTestLibraries'. And we do not want to update every single test, right?

Copy link
Member

Choose a reason for hiding this comment

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

It's a tradeoff we have to consider here. I'm not a huge fan of making our production code messier for the sake of tests, but the tradeoff would be to manually disable experiments for tests that shouldn't have them on, which doesn't scale well. I also don't know of a flutter test configuration where we could set a value like this for all tests. Let's leave it as you have it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe all tests should test production setup by default, otherwise we will have reliability issues. So, disabling tests manually sounds to be weak choice.

But we can chose between two options:

  1. Have production code messier by turning off experiments (this PR)
  2. Have experiments off in debug mode, with necessity to pass flags if we want to see them while we develop the app

Copy link
Member

Choose a reason for hiding this comment

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

After discussing this a little bit since we made the original change, I think option 2 is our best step forward. In an offline discussion with @jacob314, he also voiced concerns that having experiments on by default could prevent us from catching issues that only show up when experiments are disabled, which is what our users will see.

Copy link
Member

Choose a reason for hiding this comment

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

Implemented here: #4861

@polina-c polina-c merged commit f56690a into flutter:master Nov 28, 2022
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.

3 participants