Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot Reload not working for FlexLayout. Forced layout updates not pushed to Android. #20375

Closed
mikeysouthwell opened this issue Feb 6, 2024 · 7 comments
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/android 🤖 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working

Comments

@mikeysouthwell
Copy link

mikeysouthwell commented Feb 6, 2024

Description

App has to be reloaded to see FlexLayout changes.

I can change the background colour using hot reload, but any adjustments to the HorizontalOptions or VerticalOptions of the parent FlexLayout or it's child elements don't show with hot reload and the app has to be reloaded to see the changes or the BackgroundColor has to be changed to force the hot reload.

Steps to Reproduce

If you use the code below and try to change something such as the HorizontalOptions="Start" to HorizontalOptions="End" it won't show the change in the Android emulator for the second change. You have to force the refresh by changing the BackgroundColour.

<FlexLayout Direction="Row" BackgroundColor="Black" HeightRequest="48" AlignItems="Start" JustifyContent="Start" HorizontalOptions="Start" VerticalOptions="Start">
    <!-- Child FlexLayout on the left with a 24x24 pixel Rectangle inside -->
    <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Start" BackgroundColor="LightBlue" FlexLayout.Basis="48" FlexLayout.Grow="1" Margin="6,0,0,0">
        <Rectangle WidthRequest="24" HeightRequest="24" Fill="Blue" />
    </FlexLayout>

    <!-- Child FlexLayout on the right with 3 FlexLayouts inside it -->
    <FlexLayout Direction="Row" VerticalOptions="Start" AlignItems="Start" JustifyContent="SpaceBetween" BackgroundColor="Grey" FlexLayout.Basis="144">
        <!-- Each of these FlexLayouts has a 24x24 pixel Rectangle inside -->
        <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Center" BackgroundColor="Pink" FlexLayout.Basis="48">
            <Rectangle WidthRequest="24" HeightRequest="24" Fill="Red" />
        </FlexLayout>
        <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Center" BackgroundColor="LightGreen" FlexLayout.Basis="48">
            <Rectangle WidthRequest="24" HeightRequest="24" Fill="Green" />
        </FlexLayout>
        <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Center" BackgroundColor="LightYellow" FlexLayout.Basis="48">
            <Rectangle WidthRequest="24" HeightRequest="24" Fill="Yellow" />
        </FlexLayout>
    </FlexLayout>
</FlexLayout>

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

34.0.43

Did you find any workaround?

No response

Relevant log output

No response

@mikeysouthwell mikeysouthwell added the t/bug Something isn't working label Feb 6, 2024
@drasticactions
Copy link
Contributor

@mikeysouthwell The changes you're making via Hot Reload are being applied to the view (As in, the values are in the literal object and set), the issue is with FlexLayout on Android. It's not relaying out the view when you make programmatic changes to those child elements. If you force the view to update (rotate the device, resize the app window if on a tablet or WSA) it should show the correct value. You would see the same issues if you made programmatic changes to those elements outside of using the Hot Reload tooling.

So the bug to be fixed is forcing layout updates in FlexLayout on Android, the Hot Reload tooling itself is working correctly.

@mikeysouthwell mikeysouthwell changed the title Hot Reload not working for FlexLayout. Hot Reload not working for FlexLayout. Forced layout updates not pushed to Android. Feb 6, 2024
@mikeysouthwell
Copy link
Author

Thanks for the prompt response drasticactions. I am using the Android Emulator (Pixel 5 API 33:5554). I am unable to force the view to update. I have tried zooming in using the magnifying glass on the emulators and resizing the emulator window to force it to update, but it doesn't make a difference. Is there another way to force the view to update? I'm using an emulator, not a physical Android device or WSA.

@Eilon Eilon added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label Feb 7, 2024
@PureWeen PureWeen added the s/needs-repro Attach a solution or code which reproduces the issue label Feb 9, 2024
@ghost
Copy link

ghost commented Feb 9, 2024

Hi @mikeysouthwell. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@mikeysouthwell
Copy link
Author

Hey MSFTBOT, if you use the code below and try to change something such as the HorizontalOptions="Start" to HorizontalOptions="End" it won't show the change in the Android emulator for the second change. You have to force the refresh by changing the BackgroundColour.

<FlexLayout Direction="Row" BackgroundColor="Black" HeightRequest="48" AlignItems="Start" JustifyContent="Start" HorizontalOptions="Start" VerticalOptions="Start">
    <!-- Child FlexLayout on the left with a 24x24 pixel Rectangle inside -->
    <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Start" BackgroundColor="LightBlue" FlexLayout.Basis="48" FlexLayout.Grow="1" Margin="6,0,0,0">
        <Rectangle WidthRequest="24" HeightRequest="24" Fill="Blue" />
    </FlexLayout>

    <!-- Child FlexLayout on the right with 3 FlexLayouts inside it -->
    <FlexLayout Direction="Row" VerticalOptions="Start" AlignItems="Start" JustifyContent="SpaceBetween" BackgroundColor="Grey" FlexLayout.Basis="144">
        <!-- Each of these FlexLayouts has a 24x24 pixel Rectangle inside -->
        <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Center" BackgroundColor="Pink" FlexLayout.Basis="48">
            <Rectangle WidthRequest="24" HeightRequest="24" Fill="Red" />
        </FlexLayout>
        <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Center" BackgroundColor="LightGreen" FlexLayout.Basis="48">
            <Rectangle WidthRequest="24" HeightRequest="24" Fill="Green" />
        </FlexLayout>
        <FlexLayout Direction="Row" AlignItems="Center" VerticalOptions="Start" JustifyContent="Center" BackgroundColor="LightYellow" FlexLayout.Basis="48">
            <Rectangle WidthRequest="24" HeightRequest="24" Fill="Yellow" />
        </FlexLayout>
    </FlexLayout>
</FlexLayout>

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Feb 10, 2024
@jaosnz-rep
Copy link

Verified this issue with Visual Studio 17.10.0 Preview 2 (8.0.14 & 8.0.3), can not repro it on Android platform.

@jaosnz-rep jaosnz-rep added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Apr 1, 2024
Copy link
Contributor

Hi @mikeysouthwell. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@joegreen690
Copy link

I'm using Visual Studio Community 2022 v17.9.5 and this issue still exists. Hot Reloading is still buggy. Please do not close.

@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/android 🤖 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants