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

fix(MM-62375): OOM on gif #8573

Merged
merged 3 commits into from
Feb 12, 2025
Merged

fix(MM-62375): OOM on gif #8573

merged 3 commits into from
Feb 12, 2025

Conversation

rahimrahman
Copy link
Contributor

Summary

Ticket Link

Fixes: https://mattermost.atlassian.net/browse/MM-62375

See changes in my own fork of APNG4Android (until I have permission to post to mattermost/APNG4Android): rahimrahman/APNG4Android@74dd31c

Checklist

  • Added or updated unit tests (required for all new features)
  • Has UI changes
  • Includes text changes and localization file updates
  • Have tested against the 5 core themes to ensure consistency between them.
  • Have run E2E tests by adding label E2E iOS tests for PR.

Device Information

This PR was tested on:

Google Pixel 6a, Android 14

Screenshots

Release Note


@mm-cloud-bot mm-cloud-bot added kind/bug Categorizes issue or PR as related to a bug. release-note labels Feb 8, 2025
Comment on lines +10 to +15
+ implementation project(':frameanimation')
+ implementation project(':gif')
+ implementation("com.github.penfeizhou.android.animation:glide-plugin:3.0.2") {
+ exclude group: 'com.github.penfeizhou.android.animation', module: 'frameanimation'
+ exclude group: 'com.github.penfeizhou.android.animation', module: 'gif'
+ }
Copy link
Contributor Author

@rahimrahman rahimrahman Feb 8, 2025

Choose a reason for hiding this comment

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

The fixes are in frameanimation & gif.

Now in this PR (that will not get merged).

Comment on lines 49 to 52
APNG4Android="node_modules/APNG4Android"
if [ ! -z "$APNG4Android" ]; then
git clone -b "fix/MM-62375-oom-on-gif" --single-branch https://github.com/rahimrahman/APNG4Android.git "$APNG4Android";
fi
Copy link
Contributor Author

@rahimrahman rahimrahman Feb 8, 2025

Choose a reason for hiding this comment

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

Can't do npm i since APNG4Android doesn't have package.json.

  • TODO: will replace with mattermost/APNG4Android (as soon as permission to write is granted)
  • TODO: figure out if I can use SHA instead of branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

No you cannot clone a specific commit, but you can clone the branch and then do a checkout

Copy link
Contributor

Choose a reason for hiding this comment

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

You could also use --depth=1 so that it only clones the latest one

Comment on lines +11 to +14
include ':frameanimation'
project(':frameanimation').projectDir = new File('../node_modules/APNG4Android/frameanimation')
include ':gif'
project(':gif').projectDir = new File('../node_modules/APNG4Android/gif')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to get this as project in expo-image/android/build.gradle, need to declare frameanimation and gif here.

Comment on lines +13 to +14
+ exclude group: 'com.github.penfeizhou.android.animation', module: 'frameanimation'
+ exclude group: 'com.github.penfeizhou.android.animation', module: 'gif'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without exclusions, it will cause duplicate symbols error. Since glide-plugin will have frameanimation (required module) in other modules (apng, webp, etc).

@rahimrahman rahimrahman requested review from enahum and larkox February 8, 2025 18:58
@rahimrahman rahimrahman added the Build Apps for PR Build the mobile app for iOS and Android to test label Feb 8, 2025
@rahimrahman rahimrahman added Build App for Android Build the mobile app for Android and removed Build Apps for PR Build the mobile app for iOS and Android to test labels Feb 8, 2025
run: |
echo "::group::clone-APNG4Android"
if [ ! -d "$APNG4Android" ]; then
git clone -b "fix/MM-62375-oom-on-gif" --single-branch https://github.com/rahimrahman/APNG4Android.git "$APNG4Android";
Copy link
Contributor Author

@rahimrahman rahimrahman Feb 8, 2025

Choose a reason for hiding this comment

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

Is there any benefit of putting it into node_modules instead of a custom folder on the root path of the app?

  • TODO: Will replace this with the correct repo (mattermost/APNG4Android)

Copy link
Contributor

Choose a reason for hiding this comment

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

Irrelevant in my opinion, but of it works here no need to change

Copy link
Contributor Author

@rahimrahman rahimrahman Feb 10, 2025

Choose a reason for hiding this comment

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

I like node_modules because it's easier to do the npm run clean and it'll auto-clean this library as well. But I could also have added an extra line to clean the folder wherever it might be in scripts/clean.sh as well.

I'll stick with node_modules.

@rahimrahman rahimrahman added Build App for Android Build the mobile app for Android and removed Build App for Android Build the mobile app for Android labels Feb 9, 2025
@@ -54,7 +54,7 @@
"expo-application": "6.0.1",
"expo-crypto": "14.0.1",
"expo-device": "7.0.1",
"expo-image": "2.0.3",
"expo-image": "2.0.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to bump this? Just curious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a mistake when reading the changelog. And looking at the changes, I thought the addition of try..catch was going to help, but it didn't. Looking deeper, I noticed that it was already implemented in 2.0.3, not a new change in 2.0.4.

Changelog for 2.0.4:

## 2.0.4 — 2025-01-10

_This version does not introduce any user-facing changes._

So it's pretty moot.

Comment on lines 49 to 52
APNG4Android="node_modules/APNG4Android"
if [ ! -z "$APNG4Android" ]; then
git clone -b "fix/MM-62375-oom-on-gif" --single-branch https://github.com/rahimrahman/APNG4Android.git "$APNG4Android";
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

No you cannot clone a specific commit, but you can clone the branch and then do a checkout

Comment on lines 49 to 52
APNG4Android="node_modules/APNG4Android"
if [ ! -z "$APNG4Android" ]; then
git clone -b "fix/MM-62375-oom-on-gif" --single-branch https://github.com/rahimrahman/APNG4Android.git "$APNG4Android";
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also use --depth=1 so that it only clones the latest one

@rahimrahman rahimrahman added Build Apps for PR Build the mobile app for iOS and Android to test and removed Build App for Android Build the mobile app for Android labels Feb 10, 2025
@rahimrahman
Copy link
Contributor Author

@yasserfaraazkhan I'm flagging you for QA review, but @enzowritescode has done the test with his Android device and ✅ it in our private DM.

You're welcome to test this as well for redundancy.

@rahimrahman
Copy link
Contributor Author

rahimrahman commented Feb 10, 2025

@yasserfaraazkhan I take that back. I think you should run this app on Android, and find or create channel with lots of images (gif specifically, and animated gif if possible or both). Particularly as big images resolution as you can post (starting with 100x100 to as high as you can think of). I'm curious if the images will show up at all.

Ugh.

@yasserfaraazkhan
Copy link
Contributor

Thank you @rahimrahman I could verify the changes work.
I saw current PR display the gifs without crashing.

@rahimrahman
Copy link
Contributor Author

@amyblais Hi. Since this is a security vuln issue, it should be included in 2.26. I await @enzowritescode to either move with the go ahead to have this as a patch 2.25 and to be release immediately.

@amyblais amyblais added this to the v2.26.0 milestone Feb 11, 2025
@amyblais amyblais added the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Feb 11, 2025
@rahimrahman
Copy link
Contributor Author

@amyblais based on this discussion, I think we'd need to cherry-pick this as a 2.25.1 as well.

@amyblais amyblais removed the 3: Security Review Review requested from Security Team label Feb 12, 2025
@rahimrahman rahimrahman merged commit 985fa69 into main Feb 12, 2025
24 checks passed
@rahimrahman rahimrahman deleted the fix/MM-62375-OOM-on-gif branch February 12, 2025 15:18
@mattermost-build
Copy link
Contributor

Cherry pick is scheduled.

mattermost-build pushed a commit that referenced this pull request Feb 12, 2025
* fix(MM-62375): OOM on gif
* add APNG4Android into github action script to download
* change to mattermost/APNG4Android

(cherry picked from commit 985fa69)
@mattermost-build mattermost-build added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Feb 12, 2025
rahimrahman added a commit that referenced this pull request Feb 12, 2025
* fix(MM-62375): OOM on gif
* add APNG4Android into github action script to download
* change to mattermost/APNG4Android

(cherry picked from commit 985fa69)

Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
@amyblais
Copy link
Member

/cherry-pick release-2.25

@mattermost-build
Copy link
Contributor

Cherry pick is scheduled.

mattermost-build pushed a commit that referenced this pull request Feb 14, 2025
* fix(MM-62375): OOM on gif
* add APNG4Android into github action script to download
* change to mattermost/APNG4Android

(cherry picked from commit 985fa69)
amyblais pushed a commit that referenced this pull request Feb 14, 2025
* fix(MM-62375): OOM on gif
* add APNG4Android into github action script to download
* change to mattermost/APNG4Android

(cherry picked from commit 985fa69)

Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
Willyfrog pushed a commit that referenced this pull request Feb 19, 2025
* fix(MM-62375): OOM on gif
* add APNG4Android into github action script to download
* change to mattermost/APNG4Android
Rajat-Dabade pushed a commit that referenced this pull request Feb 25, 2025
* fix(MM-62375): OOM on gif
* add APNG4Android into github action script to download
* change to mattermost/APNG4Android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Apps for PR Build the mobile app for iOS and Android to test CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone kind/bug Categorizes issue or PR as related to a bug. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants