Giter Site home page Giter Site logo

Modal components are broken about iced_aw HOT 9 CLOSED

iced-rs avatar iced-rs commented on July 18, 2024
Modal components are broken

from iced_aw.

Comments (9)

genusistimelord avatar genusistimelord commented on July 18, 2024

yeah I know they are still broken but I still do not know Why it is broken as its been really hard to trace the reason for this. The example I have in there is to help trace and to know when it is finally fixed or not.

from iced_aw.

turai avatar turai commented on July 18, 2024

My very shallow investigation suggests this doesn't really have anything to do with this crate, ran into the exact same panic while messing with my own components, but I'd rather keep this issue open to warn others.

from iced_aw.

genusistimelord avatar genusistimelord commented on July 18, 2024

yeah that's fine. I suspect it has something to do with something Iced itself is doing but again its hard to track down. Like I can see where it error-ed but i cant see why it had an error. Made me feel like something thread wise is missing data. Or something ran before something else which made the data not yet appear. I will keep this comment open for others and ill point @hecrj here too.

from iced_aw.

TheComamba avatar TheComamba commented on July 18, 2024

I ran into this some days ago and created an even more minimal example before discovering this issue. Just in case it might help, it can be found here.

from iced_aw.

TheComamba avatar TheComamba commented on July 18, 2024

Preliminary analysis:

  1. Modal::new calls the into() implementation of MyComponent.
  2. into() is implemented via iced_lazy::component.
  3. component() calls Element::new() in component.rs, setting tree to None.
  4. I'm not sure how, but then diff() in modal.rs is called.
  5. This in turn calls state() in component.rs, setting tree to Some. So far so good.
  6. Then iced_nativ::user_interface::UserInterface::update calls Modal::overlay.
  7. Here we call ModalOverlay::new(). One of the arguments is (self.content)(). We evaluate the function that is content.
  8. Because of this re-evaluation, iced_lazy::component is called again.
  9. component(), calls Element::new() again and resets tree to None.
  10. Still in UserInterface::update, we run into Element::layout().
  11. This eventually calls Instance::rebuild_element_if_necessary in component.rs.
  12. And now this function expects a tree to present, but because state was never called again since step 8, it is None.

My rather uneducated guess is that this could be avoided by not making content a (function yielding an Element), but simply an Element. However I cannot fathom what would break by doing that, and I do not know the design considerations that went into making it a function.

from iced_aw.

genusistimelord avatar genusistimelord commented on July 18, 2024

this seems like a iced issue then if it has to do when the state is being called. I wonder if there is something we can do to ensure the state is made and set. Also no idea why they designed it that way originally.

from iced_aw.

hecrj avatar hecrj commented on July 18, 2024

This is an iced issue. Component currently breaks the Widget contract. A proper fix isn't straightforward. I'll think about it.

In the meanwhile, we can call Widget::diff for the content before passing it to the ModalOverlay to ensure the widget tree has the proper state set.

from iced_aw.

genusistimelord avatar genusistimelord commented on July 18, 2024

@turai and @TheComamba can you please try the latest Main branch of iced_aw. I believe the new push fixes this issue.

If this did fix the issue then Great I can release it as a patched version. But I will be probably making a breaking change on this in the next Iced release to make it a Element instead of a closure. as I see no need for it to be a closure.

from iced_aw.

TheComamba avatar TheComamba commented on July 18, 2024

@genusistimelord Nice, it works indeed! Thank you! :)

from iced_aw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.