CommunityToolkit / CommunityToolkit/Maui

[BUG] StatusBar.Android.PlatformSetColor() breaks ViewTreeObserver.IOnGlobalLayoutListener

Open
#2,289 3 comments 0 reactions 0 assignees View on GitHub
area/behaviors bug unverified
Dominant language
C#
Stars
2.7k
Forks
500
Avg merge
2d 14h
Merged PRs (30d)
7

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Did you read the "Reporting a bug" section on Contributing file?

- [x] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

### Current Behavior

This PR https://github.com/CommunityToolkit/Maui/pull/1630 has broken ViewTreeObserver.IOnGlobalLayoutListener on Android API 29 and (protentional below).
```
var listener = new WindowInsetsOldApiListener(activity.Window.DecorView);
activity.Window.DecorView.RootView?.ViewTreeObserver?.AddOnGlobalLayoutListener(listener);
```

### Expected Behavior

ViewTreeObserver.IOnGlobalLayoutListener works as before the PR https://github.com/CommunityToolkit/Maui/pull/1630

### Environment

- .NET MAUI CommunityToolkit: 9.0.3 and 9.1.0
- OS: Windows
- .NET MAUI: .NET 8.0.91

### Anything else?

Can't confirm which line of code in the PR has broken ViewTreeObserver.IOnGlobalLayoutListener. Also can't easily test the bug on Android emulators API 29 and below due to an old version of WebView on such emulators. I have a project using BlazorWebView. As I get more info I'll be back.
What I can say for sure is reverting the PR https://github.com/CommunityToolkit/Maui/pull/1630 and using CommunityToolkit as a .dll makes ViewTreeObserver.IOnGlobalLayoutListener work normally.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.