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

[Android][MAUI-8.0.7] CPU usage consistently remains above 10%, even without any operation #20684

Open
BaY1251 opened this issue Feb 19, 2024 · 13 comments · May be fixed by #22628
Open

[Android][MAUI-8.0.7] CPU usage consistently remains above 10%, even without any operation #20684

BaY1251 opened this issue Feb 19, 2024 · 13 comments · May be fixed by #22628
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView delighter-sc platform/android 🤖 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look t/bug Something isn't working t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.)
Milestone

Comments

@BaY1251
Copy link

BaY1251 commented Feb 19, 2024

Description

When there is a 'CollectionView' with property set to ItemsLayout="HorizontalList", the interface responds very slowly.CPU is always occupied, maintaining around 20%

Steps to Reproduce

Download https://github.com/BaY1251/MauiDebug.git

  1. Open /HorizontalList/HorizontalList.sln
  2. Change configuration to 'Release', and deployment the project
  3. Wait for 5 minutes, do not take any action during this period
  4. Command line input adb shell top -n 1 | findstr "\<com.companyname.horizontallist\> \<PID\>"' to view CPU usage.
  5. Waiting for what you think is a long enough time
  6. Command line input adb shell top -n 1 | findstr "\<com.companyname.horizontallist\> \<PID\>"' to view CPU usage.

Link to public reproduction project repository

https://github.com/BaY1251/MauiDebug.git

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.6 SR1

Affected platforms

Android

Affected platform versions

Android7.1

Did you find any workaround?

No response

Relevant log output

No response

@BaY1251 BaY1251 added the t/bug Something isn't working label Feb 19, 2024
@jsuarezruiz jsuarezruiz added platform/android 🤖 legacy-area-perf Startup / Runtime performance area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Feb 19, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Feb 19, 2024
@ghost
Copy link

ghost commented Feb 19, 2024

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@samhouts samhouts added the potential-regression This issue described a possible regression on a currently supported version., verification pending label Feb 20, 2024
@moljac
Copy link
Contributor

moljac commented Feb 26, 2024

  • could not repro

    • all tests - 0%-3%

    • manual too

  • TODO: tests on another dev box (Mac x86) with net7.0, net8.0, net9.0

  • 1000 samples - approx 1 sec each

  • tested

    • 2 macs

      • M2

      • x86 i9

    • on

      • emulators

      • pixel5 device

        I was not able

emulator-mac-m2-net8.0.top.processor.log.txt
emulator-mac-m2-net7.0.top.processor.log.txt

repro sample

AppRepro.zip

Mac M2 pixel5 net8.0

  • crash during start (needs investigation)

    • workaround - nuke bin/ obj/
dotnet build \
    ./net8.0/ProjectsStructureTemplate.AppMAUI.DemoSample/ProjectsStructureTemplate.AppMAUI.DemoSample.csproj \
    -t:run \
    -f:net-8.0-android
adb shell top -n 1000 | grep "com.companyname" > pixel5--net8.0.top.processor.log

Could not redirect output to file. Redirecting hangs.

adb shell top -n 1000

Does not even list tested app

adb shell top -n 1000 | grep "com.companyname"                                  

shows around 3% (constant)

20790 u0_a56       10 -10  14G 227M 121M S  1.3   3.0   0:04.22 com.companyname+
20790 u0_a56       10 -10  14G 227M 121M S  1.3   3.0   0:04.22 com.companyname+

Mac M2 emulator net8.0 - OK

dotnet build \
    ./net8.0/ProjectsStructureTemplate.AppMAUI.DemoSample/ProjectsStructureTemplate.AppMAUI.DemoSample.csproj \
    -t:run \
    -f:net-8.0-android
adb shell top -n 1000 | grep "com.companyname" > emulator-2--net8.0.top.processor.log

Mac M2 emulator net7.0 - OK

dotnet build \
    ./net7.0/ProjectsStructureTemplate.AppMAUI.DemoSample/ProjectsStructureTemplate.AppMAUI.DemoSample.csproj \
    -t:run \
    -f:net-7.0-android
adb shell top -n 1000 | grep "com.companyname" > emulator-2--net7.0.top.processor.log

@BaY1251
Copy link
Author

BaY1251 commented Feb 27, 2024

@moljac
I noticed that my project seems to have been modified, please make sure to use <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" /> instead of <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />

Or,
Can you directly deploy my project? I am certain that the issue introduced in the new version(8.0.7) occurred in Android 7.1, while the old version did not have this issue

@BaY1251
Copy link
Author

BaY1251 commented Feb 27, 2024

image

@moljac
Copy link
Contributor

moljac commented Feb 27, 2024

I noticed that my project seems to have been modified,

yes. I have template for multi TFM tests. I tried your sample. There was some processor %, but not 20%.

I will paste logs today.

please make sure to use <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" /> instead of <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />

I will add those references to my projects.

Or, Can I directly deploy my project?

Can you? I guess you can. I did. Yes there was some % but not 20%.

The reason I use my template is to find possible regressions if any.

I am certain that the issue introduced in the new version(8.0.7) occurred in Android 7.1, while the old version did not have this issue

OK. Good to know. I will test more today.

@moljac
Copy link
Contributor

moljac commented Feb 28, 2024

OK. I was able to repro

with

<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />

it is not 20%, but 10% original sample and 12% for my sample.

18801 u0_a190      10 -10  14G 244M 114M S 33.6  12.3  14:57.95 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 33.6  12.3  14:58.96 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 34.0  12.3  14:59.97 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 34.6  12.3  15:00.99 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 34.0  12.3  15:02.03 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 33.3  12.3  15:03.05 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 34.3  12.3  15:04.05 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 34.6  12.3  15:05.08 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 34.3  12.3  15:06.12 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 33.6  12.3  15:07.15 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 34.3  12.3  15:08.16 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 33.6  12.3  15:09.19 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 34.6  12.3  15:10.20 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 34.3  12.3  15:11.24 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 34.0  12.3  15:12.27 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 34.0  12.3  15:13.29 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 33.3  12.3  15:14.31 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 35.0  12.3  15:15.31 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 34.3  12.3  15:16.36 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 34.6  12.3  15:17.39 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 35.3  12.3  15:18.43 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 35.0  12.3  15:19.49 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 34.3  12.3  15:20.54 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 32.6  12.3  15:21.57 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 24.3  12.3  15:22.55 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M R 24.3  12.3  15:23.28 com.companyname+
18801 u0_a190      10 -10  14G 244M 114M S 24.0  12.3  15:24.01 com.companyname+

@BaY1251
Copy link
Author

BaY1251 commented Feb 29, 2024

Thank you very much. These data are sufficient to illustrate the issue, as other versions are close to 0%.

PS:
20% was the initial test, with a lot of interface elements to demonstrate slow interface response.
Later, I found that the CPU was sufficient to explain the problem, so I will modify the title.

@BaY1251 BaY1251 changed the title [Android][MAUI-8.0.7] The CPU always maintains around 20%, even without any operation [Android][MAUI-8.0.7] CPU usage consistently remains above 10%, even without any operation Feb 29, 2024
@BaY1251
Copy link
Author

BaY1251 commented Apr 3, 2024

can repro in Net9 pre 2?

@BaY1251
Copy link
Author

BaY1251 commented Apr 10, 2024

can repro in MAUI-8.0.20

@BaY1251
Copy link
Author

BaY1251 commented Apr 26, 2024

This may not be just a problem with CollectionView. I tried using ScrollView+HorizontalStackLayout instead, but the problem still occurred.

@Eilon Eilon added t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) and removed legacy-area-perf Startup / Runtime performance labels May 10, 2024
BaY1251 added a commit to BaY1251/maui that referenced this issue May 22, 2024
This change comes from dotnet#19349, which simply and crudely piles up a large number of threads before loading the interface,Causing a significant decrease in performance.
I don't have a better way, so I have to delete it
@PureWeen
Copy link
Member

Can you test with the latest nightly build?
https://github.com/dotnet/maui/wiki/Nightly-Builds

@PureWeen PureWeen added the s/needs-info Issue needs more info from the author label May 22, 2024
@PureWeen
Copy link
Member

I tested the repro here and I no longer see any ping ponging with the latest nightly

	<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.60-ci.net8.24272.1" />
	<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.60-ci.net8.24272.1" />

@BaY1251
Copy link
Author

BaY1251 commented May 23, 2024

Yes, fixed by PR #22347

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels May 23, 2024
@BaY1251 BaY1251 linked a pull request May 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView delighter-sc platform/android 🤖 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look t/bug Something isn't working t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants