Skip to content

Fix: IndexedStack says its children are offstage when dumping render tree, but they are indeed onstage and users get confused#122393

Closed
fzyzcjy wants to merge 1 commit intoflutter:masterfrom
fzyzcjy:patch-26
Closed

Fix: IndexedStack says its children are offstage when dumping render tree, but they are indeed onstage and users get confused#122393
fzyzcjy wants to merge 1 commit intoflutter:masterfrom
fzyzcjy:patch-26

Conversation

@fzyzcjy
Copy link
Contributor

@fzyzcjy fzyzcjy commented Mar 10, 2023

Close #111478

Please see #111479 (comment) for context.

This is a tentative PR, since I am not very sure what do Flutter team think about this. If you think it is OK, I will add tests, polish it (e.g. adding a longer issue) etc!

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Mar 10, 2023
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Comment on lines +784 to +785
// Though those children are indeed offstage, the current
// `debugVisitOnstageChildren` wrongly treat them as onstage.
Copy link
Member

Choose a reason for hiding this comment

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

This sounds like a bug in debugVisitOnstageChildren. Is there an issue for it in the tracker?

In general the Flutter approach to this situation is to strongly prefer fixing the underlying bug, rather than adding a workaround:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#lazy-programming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's definitely a bug on debugVisitOnstageChildren. However, someone has tried to fix that in #111479 (comment), but that PR was closed because it was breaking change, and added to #24722.

Thus, I guess we have to do this PR if we do not want to confuse the users :/

@gnprice
Copy link
Member

gnprice commented Mar 17, 2023

Hmm, I see. I agree, it looks like the path of trying to fix the underlying bug has been explored, and it's appropriate to apply a workaround.

In that case what that point reduces to is: this should have a comment linking to the issue, namely #111478 .

And then the high-level question for this PR is how to balance:

  • Showing these children as offstage is confusing, because they're not recognized as offstage by a test finder.
  • Showing these children as onstage is confusing, because they're not onstage in that they're not rendered or hit-tested.

In other words, #111478 means that the behavior outside of this method is inconsistent, and so whichever way it picks will fail to match some of that behavior.

I don't feel informed enough about this area to have a view on which of those is least bad.

I wonder if it could make sense to add into this tree dump a little note about this mismatch? Perhaps by adding a child that's made with [DiagnosticsNode.message]. The note could convey the information either of "btw these offstage children won't match an offstage finder", or "btw most of these children aren't rendered or hit-tested".

Relatedly, it seems like knowing which child is the currently truly-onstage one will often be pretty important information. So if that isn't conveyed by the two different styles, it should be conveyed some other way.

@HansMuller HansMuller requested a review from goderbauer March 17, 2023 21:58
@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented Mar 17, 2023

this should have a comment linking to the issue, namely #111478

done

I wonder if it could make sense to add into this tree dump a little note about this mismatch? Perhaps by adding a child that's made with [DiagnosticsNode.message].

Yes I think so, that would be helpful

I don't feel informed enough about this area to have a view on which of those is least bad.

Just ping me when the decision is made :)

@goderbauer
Copy link
Member

I agree with the previous post that this just moves the confusion to a different place and therefore I am leaning towards not making this fix. It is odd to "break" something that used to work just to make it consistent with something we know is broken.

We could explore how breaking making the real fix is again. Unfortunately, the previous attempt at fixing this didn't note how many google targets were effected by this. If it is just a few, we could potentially hand-fix them and write a migration guide. If someone posts a PR with the real fix, I can run the internal tests again.

@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented Mar 21, 2023

That looks reasonable! @simolus3 hi could you please re-create the PR as suggested above? (I can do so but think it is impolite to "steal" others' code)

@simolus3
Copy link
Contributor

I've opened #123129 again.

@goderbauer
Copy link
Member

Thanks. I am going to close this one in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Widget test] Make IndexedStack hide non-active children from finder

4 participants