Repository navigation
Conversation
72792dc to
7de12d6
Compare
5a8061d to
7e00038
Compare
|
Hey @Gustl22 do you want to continue working on this change? If so, please mark it ready for review when it is (it is currently a draft). It looks like there are a bunch of unrelated changes included here as well. |
|
Thank you for reaching out @Piinks As explained in this issue description, I would like to know whether Widgets should be laid out, if they are hidden behind some sort of overlay (offstaged). This is handled differently in the two widgets The unrelated code changes are just some code to try out my stuff and will get transitioned to proper tests, once the solution is applied. Thank you for any further information in that direction. |
|
I think the correct approach to actually always lay it out regardless if its offstaged (how its currently handled in offstage widget). I suppose technically it's already like this, because the underlaying Overlay is almost always implicitely layed out before the second overlay is pushed on top. Except in this case for web, where both overlays are injected simultaneously, so this bug occurs. |
|
Thanks for the update!
Unfortunately the unrelated code makes it difficult to discern what this change is. Can you remove the unrelated code so we can better understand what you are trying to change here? |
7e00038 to
b2cf9f7
Compare
|
@Piinks thank you for getting back. I updated the PR to the latest main state, kept in the reproduction example (but removed every unnecessary stuff). Approach 1: Avoid painting Ink RenderObjects, which are not visible: This is what I have tried so far in this PR, but I think that's wrong (it's not done like that in e.g. Offstage widget). Approach 2: Just lay out every overlay in the widget tree (I don't mean render). This is how its done in the Hope the problem get's more clearly. It's hard to explain unless one executes the steps in the reproduciton sample (Web only). But the general question keeps the same (even without looking into the code). |
|
Thanks for the update! Hmm, I wonder if @LongCatIsLooong knows why the Overlay behaves differently than Offstage when children are not visible. It does seem like an intentional behavior. |
|
Do you mean Overlay skipping laying out obstructed OverlayEntries? Yes that's intended, we don't want to keep doing layout computations for offscreen routes because that could be expensive and it scales as the number of offscreen routes increases. Typically we only want to do work for what is onscreen (we do rebuild the widget tree even for offscreen widgets though). |
|
Drive-by comment: can you add a simple explanation to help reviewers understand why this issue is happening? Also the original issue is created one year ago. There are some recent changes made to LayoutBuilder so I'm not sure the original issue still exists / is going to hit the same assertion.
The issue is about a layout assert so why do we need to make changes to the painting logic? Aslo IIRC Ink stuff already checks |
78babe0 to
954eb8b
Compare
|
Hi there @LongCatIsLooong,
Yes, that is kind of confusing, it should be the case for
That was my hope, too, but it still is a problem with the most recent main.
I now could further shrink down the code to only framework components: import 'package:flutter/material.dart';
/// Flutter code sample for [Overlay].
void main() {
// debugRepaintRainbowEnabled = true;
// debugPrintMarkNeedsLayoutStacks = true;
// debugPrintMarkNeedsPaintStacks = true;
// debugPrintLayouts = true;
runApp(const OverlayApp());
}
class OverlayApp extends StatelessWidget {
const OverlayApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(home: OverlayExample());
}
}
class OverlayExample extends StatefulWidget {
const OverlayExample({super.key});
@override
State<OverlayExample> createState() => _OverlayExampleState();
}
class _OverlayExampleState extends State<OverlayExample> {
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Material( // <- InkDecoration is registered here
child: Overlay(
initialEntries: [
OverlayEntry( // Offstaged and therefore not layouted
builder: (BuildContext context) {
return Ink(child: Container(width: 111, height: 112, color: Colors.red));
},
opaque: true,
canSizeOverlay: true,
maintainState: true,
),
OverlayEntry(
builder: (BuildContext context) {
return Container(width: 222, height: 223, color: Colors.blue);
},
opaque: true,
canSizeOverlay: true,
maintainState: true,
),
],
),
);
}
}
Typically one uses a
Options:
|
|
@Gustl22, what are you missing for this PR? Also, I'm having trouble understanding what you are doing. It looks like you are only printing and creating |
|
@ValentinVignal I hadn't had time to evaluate which fix is the most appropriate one, but I guess it is the one to just ignore the assertion. The code in this PR is not fixing anything (yet). I will transfer the examples to proper tests and then propose a fix and unmark as DRAFT. What would help me though, is which of these options described above you would prefer (although the solution might differ for
The other thing that came into consideration is that other widgets with different behavior such as TL;DR: I need more time to provide a proper fix. |
43a72dd to
76f5a75
Compare
|
Hi @Gustl22 is this a change you plan to continue working on? |
|
I would love to, but need a deeper understanding of the second case of failure. Maybe one can clarify my question above. In the mean time, I will close the PR until I have enough time and I can properly provide a fix. |
DRAFT of trying to solve assertion issues on painting Ink in a stacked route (via Overlay).
Note: The
Offstagewidget actually layouts the widgets, even if they are not shown. So other widgets can interact with it and know its size. On the other hand, the Overlay widget ignores them during layout, but still has them in the widget tree.So the question is, should
Overlaybehave the same asOffstage? If not, then painting should be forbidden forRenderboxeswhich haven't laid out (have no size) to ensure, e.g.Inkis not throwing an error.Contributes to #147452 and
Closes #151536
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.