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

Use drawable directly for split tunneling app icons #7879

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

Pururun
Copy link
Contributor

@Pururun Pururun commented Mar 25, 2025

Also add a loading circle instead of the missing app icon image


This change is Reviewable

Copy link

linear bot commented Mar 25, 2025

Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

private const val MAX_BITMAP_SIZE_BYTES = 100 * 1024 * 1024

fun Drawable.isBelowMaxSize(): Boolean =

I am not sure if this is needed anymore as it was a stopgap fix for a check in BitmapPainter and we are no longer using it. I think though that we should have some kind of safeguard for homongous app icons that for some reason exists.

@Pururun Pururun added the Android Issues related to Android label Mar 25, 2025
@Pururun Pururun force-pushed the investigate-splittunneling-application-icon-droid-501 branch from 5208ef2 to b2afec2 Compare March 25, 2025 13:50
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 10 files reviewed, 1 unresolved discussion (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

I am not sure if this is needed anymore as it was a stopgap fix for a check in BitmapPainter and we are no longer using it. I think though that we should have some kind of safeguard for homongous app icons that for some reason exists.

We should verify this still works because I remember us having crashes because some app had a icon of many MB in size.

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 9 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: 2 of 10 files reviewed, 1 unresolved discussion (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

We should verify this still works because I remember us having crashes because some app had a icon of many MB in size.

See DROID-846 for more info

Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 10 files reviewed, 1 unresolved discussion (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

See DROID-846 for more info

@Override
    protected void throwIfCannotDraw(Bitmap bitmap) {
        super.throwIfCannotDraw(bitmap);
        int bitmapSize = bitmap.getByteCount();
        if (bitmapSize > MAX_BITMAP_SIZE) {
            throw new RuntimeException(
                    "Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap.");
        }
    }

Yes here, however it is no longer called as far as I can tell?

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 10 files reviewed, 1 unresolved discussion (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…
@Override
    protected void throwIfCannotDraw(Bitmap bitmap) {
        super.throwIfCannotDraw(bitmap);
        int bitmapSize = bitmap.getByteCount();
        if (bitmapSize > MAX_BITMAP_SIZE) {
            throw new RuntimeException(
                    "Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap.");
        }
    }

Yes here, however it is no longer called as far as I can tell?

Ah, you mean since we no longer us Bitmap to begin with? Yeah, could be true. I just mean we should try and reproduce the old bug as with this code. Just add a icon of 100MB + and see that it renders it fine.

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 10 files reviewed, 2 unresolved discussions (waiting on @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r2 (raw file):

private const val MAX_BITMAP_SIZE_BYTES = 100 * 1024 * 1024

fun Drawable.isBelowMaxSize(): Boolean =

We should remove the old corresponding function that existed on bitmap as well.

Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 10 files reviewed, 2 unresolved discussions (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

Ah, you mean since we no longer us Bitmap to begin with? Yeah, could be true. I just mean we should try and reproduce the old bug as with this code. Just add a icon of 100MB + and see that it renders it fine.

Yes will do


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r2 (raw file):

Previously, Rawa (David Göransson) wrote…

We should remove the old corresponding function that existed on bitmap as well.

Removed

Rawa
Rawa previously approved these changes Mar 25, 2025
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 9 files at r1, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

Yes will do

👍 Given this is done, I approve! Well done! 👏


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 6 at r3 (raw file):

import android.graphics.drawable.Drawable

private const val MAX_BITMAP_SIZE_BYTES = 100 * 1024 * 1024

nit: Maybe just add a comment saying it is 100MB

Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 11 files reviewed, 2 unresolved discussions (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

Yes will do

Tested with a test app with a ridicolous size icon (10 000x10 000) and it did not crash! That icon did crash the app on main so I guess not converting to bitmap has some other benefits as well. I tink we should keep the bitmap drawable check just in case.

@Pururun Pururun force-pushed the investigate-splittunneling-application-icon-droid-501 branch 2 times, most recently from c060e18 to 4ed1799 Compare March 26, 2025 10:41
Rawa
Rawa previously approved these changes Mar 26, 2025
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 9 files at r1, 1 of 1 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 8 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

Tested with a test app with a ridicolous size icon (10 000x10 000) and it did not crash! That icon did crash the app on main so I guess not converting to bitmap has some other benefits as well. I tink we should keep the bitmap drawable check just in case.

Well done! 👏

Also add a loading circle instead of the missing app icon image
@Pururun Pururun force-pushed the investigate-splittunneling-application-icon-droid-501 branch from 4ed1799 to e8a7098 Compare March 26, 2025 10:47
Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Drawable.kt line 6 at r3 (raw file):

Previously, Rawa (David Göransson) wrote…

nit: Maybe just add a comment saying it is 100MB

Done

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r6.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@Pururun Pururun merged commit 430f8a3 into main Mar 26, 2025
31 checks passed
@Pururun Pururun deleted the investigate-splittunneling-application-icon-droid-501 branch March 26, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants