Skip to content

Poor performance creating animated gifs on Android #757

@dmanning23

Description

@dmanning23

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

I'm getting really poor performance using ImageSharp to create animated gifs on Android devices.
A rundown of the use case here:

  • Capture a few seconds of full-screen gameplay
  • Resize the screen captures BEFORE sending to ImageSharp to improve performance
  • Use ImageSharp to render everything to an animated gif in a background thread, which can then be shared on social media. The resulting gifs have 20 frames of animation and clock in at about 200-300KB in size.

I've tried a few things including bumping up the Java heap size to 2G, which was a massive improvement. Going higher doesn't improve performance though. I also updated the Supported Architectures to build for 64bit devices because the documentation mentioned it. It offered a little bit of improvement. Also switching from the "beta" to "dev" build of ImageSharp was significantly faster.

Depending on the horsepower of the device, the ImageSharp image processing takes between 10-30 seconds. My test devices here are a Samsung S7 Edge, which takes between 10-15 seconds, and a Nexus9 which takes 20-30 seconds.

All this stuff is open-source if yall want to check my work. The ImageSharp gif creation starts at:
https://github.com/dmanning23/MonogameScreenTools/blob/ebc1357f3940dac25f33d0b26096e1ef34b78919/MonogameScreenTools/MonogameScreenTools.SharedProject/GifHelper.cs#L84

The sample app I'm using to benchmark this code is at
https://github.com/dmanning23/MonogameScreenToolsExample
(If all yall would rather test from an APK I can upload that too.)

I've got no problem making the user wait 30 seconds to create a gif... I feel like people are used to waiting a little bit while uploading a video to Facebook or Youtube, so I'm not too worried about. Also this is an update to an app that has like 10 total downloads, so yeah zero fs given ;) I'd like to reuse this code in future apps though, with (hopefully!) more players, and obviously they will be more inclined to share if they only have to wait a few seconds for the gif to be created.

I've uploaded a sample of one of these animated gifs if that will help

monogamescreentoolstest_131852110485108910

Thanks again yall! Cheers!

System Configuration

The two test devices I have:

  • Samsung Galaxy S7 Edge running Android 8.0

  • Nexus9 running Android 7.1.1

  • ImageSharp version: I'm using the latest dev build from the (correct!) ImageSharp myget stream.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions