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

Disable the AndroidLinkResources optimization #7038

Merged
merged 1 commit into from
May 11, 2022
Merged

Disable the AndroidLinkResources optimization #7038

merged 1 commit into from
May 11, 2022

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented May 11, 2022

Description of Change

Disable the optimization as it causes a crash with libraries that use the resources - such as SkiaSharp. This could be any library that has Android controls defined in C# and use android styles.

However, if an app is not using any controls like this, they can still manually enable this feature and get all the wins!

Issues Fixed

Related to #7037

@mattleibow mattleibow added this to the 6.0.300 milestone May 11, 2022
@mattleibow mattleibow added platform/android 🤖 p/0 Work that we can't release without legacy-area-perf Startup / Runtime performance fatal labels May 11, 2022
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will just blog about this setting as "experimental". Probably safer to turn this off by default for now.

@Redth Redth merged commit af8e7ce into main May 11, 2022
@Redth Redth deleted the dev/fix-7037 branch May 11, 2022 18:08
jonpryor pushed a commit to dotnet/android that referenced this pull request Sep 13, 2022
)

Fixes: #7194

Context: dotnet/maui#7038

The initial version of `$(AndroidLinkResources)` (9e6ce03) was too
broad in its removal of Resource classes and fields.  Certain fields
such as `Styleable` arrays were not called using the IL `stsfld`
opcode.  As a result they could not be easily replaced with constant
usage.

However, the linker removed *all* the fields from the `Resource` 
nested types.  This would result in the following error at runtime:

	System.BadImageFormatException: 'Could not resolve field token 0x0400000b'

This was because the `int[]` fields were removed as part of the
linking process. 

Fix this by leaving the `int[]` fields in the `Resource` nested types
instead of removing them.

We can still remove all the other `int` fields.

We now also need to fix up the `Resource` nested type constructors
to replace the `int` field access with the constant values like we do
for the rest of the app.   This was not required previously because
these constructors were removed, but now we have to keep them because
the static array initialization takes place in these constructors.
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@Eilon Eilon added the t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) label May 10, 2024
@samhouts samhouts added the fixed-in-6.0.312 Look for this fix in 6.0.312! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-6.0.312 Look for this fix in 6.0.312! legacy-area-perf Startup / Runtime performance p/0 Work that we can't release without platform/android 🤖 t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants