Skip to content

[DynamicColors] Calling getDecorView in f6c8fa5aefc84a1543eca3056a538120de0b4297 breaks certain apps #2558

@sb-software

Description

@sb-software

Description:
In f6c8fa5 a call to Window#getDecorView was added. The problem with this though is that it will, as documented, lock in certain characteristics of the Window. If an embedding app has any calls to for example Window#setFlags or Window#requestFeature after DynamicColors has executed, those calls will either be ignored or cause the app to crash (with AndroidRuntimeException("requestFeature() must be called before adding content")).

Since one way to initialize DynamicColors is to let it use an ActivityLifecycleCallbacks and its onActivityPreCreated method there is a very high chance this will happen before the embedding application starts tweaking the Window characteristics. Note: there is no guarantee at all at which point an app will have initialized the decor view, it is not enforced by the framework to happen at any specific time as far as I remember.

Expected behavior: Avoid using getDecorView since it will break embedding apps in surprising ways.

Source code: f6c8fa5

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions