Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Released] Animated GIF Player

Discussion in 'Assets and Asset Store' started by Mareck, Mar 8, 2017.

  1. RenegadeNinjaNL

    RenegadeNinjaNL

    Joined:
    May 23, 2013
    Posts:
    22
    I created a custom path where I save all the captured GIFs. I added the code below in the Load function that leads to the GIF folder:
    Code (CSharp):
    1.  
    2. case GifPath.CustomPathGIF:
    3.   gifPath = Application.dataPath + System.IO.Path.DirectorySeparatorChar + "User" + System.IO.Path.DirectorySeparatorChar + "GIFs" + System.IO.Path.DirectorySeparatorChar;
    4. break;
    5.  
    It's on Windows (editor and player), Unity 5.6.6f2, and I am using the latest version of the GIF player.

    I can play the GIFs I captured during the match at the main menu, I just can't seem to play them after a match is over.
     
  2. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    The gif player can read files from one of three paths: Application.streamingAssetsPath, Application.persistentDataPath and Application.temporaryCachePath. You can set this with the GifPath property. Once set this you don't need to add this path to the FileName property. For example: when using a file with the location: StreamingAssets/Gifs/gif.gif just set GifPath to GifPath.StreamingAssetsPath and FileName = "gif.gif".

    The reason I didn't include other paths is that these three can be used the most reliable across platforms. For example. Application.dataPath can't be written to on iOS.

    Edit: I see now that you edited the GifPlayer code :). Let me take a look

    Edit: I got it working on my machine with Unity 5.6. Are you sure you have the paths set correctly?

    The complete path I am using is: C:\Users\M\Documents\GitHub\AnimatedGifPlayer\Assets\User\GIFs

    Can you put a Debug.Log(path); just before the using (var www = new WWW(path.Replace("#", "%23")))?
     
    Last edited: Jun 21, 2018
  3. RenegadeNinjaNL

    RenegadeNinjaNL

    Joined:
    May 23, 2013
    Posts:
    22
    Here what I got back in the console:
    Code (CSharp):
    1. file://F:/Documents/Unity Projects/Mad World/Assets\User\GIFs\GIF 037 - Akuto_ Mad World - Build 94.gif
    2. UnityEngine.Debug:Log(Object)
    3. OldMoatGames.<Load>c__Iterator0:MoveNext() (at Assets/AnimatedGifPlayer/Scripts/AnimatedGifPlayer.cs:353)
    4. UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    5. OldMoatGames.AnimatedGifPlayer:Init() (at Assets/AnimatedGifPlayer/Scripts/AnimatedGifPlayer.cs:248)
    6. ScoreController:ShowCapturedGIFs() (at Assets/Scripts/GUI/ScoreController.cs:190)
    7. GameOverMenuEventSystemDelay:OnEnable() (at Assets/Scripts/GUI/GameOverMenuEventSystemDelay.cs:48)
    8. UnityEngine.GameObject:SetActive(Boolean)
    9. LevelControl:GameOverVersusMode() (at Assets/Scripts/Game/LevelControl.cs:800)
    10.  
    The GIF I now captured in the match can be played in the main menu using the same code, just not after the match. Do you think it is because I set the timeScale to 0?
     
  4. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    That file path looks correct. Mine is file://C:/Users/M/Documents/GitHub/AnimatedGifPlayer/Assets\User\GIFs\AnimatedGIFPlayerExampe 3.gif. So that can't be the problem. The timescale shouldn't be an issue I think. Isn't the file being removed or something when you try to play it after the match?

    Can you try this code just before where you call the Init()method in your code after the match to list the files your gif folder?

    Code (CSharp):
    1. foreach (string file in System.IO.Directory.GetFiles("F:/Documents/Unity Projects/Mad World/Assets/User/GIFs/")) {
    2.             Debug.Log(file);
    3. }
     
  5. RenegadeNinjaNL

    RenegadeNinjaNL

    Joined:
    May 23, 2013
    Posts:
    22
    That code lists all the GIFs and meta files in the folder. There is quite a lot of GIFs, so I haven't posted the console code on here.

    I keep all the captured GIFs in the same folder so that players can re-watch them in the gallery on the main menu. The GIFs are captured during the match, and are used to show 'highlights' of stuff that happened in the match.
     
  6. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    But the one you are trying to play isn't missing there? It is very strange, since it did play before.

    Maybe something else is going on. Maybe the WWW class can't open the file because it is being written to?

    Let's make sure the file exists maybe.

    Can you add this just before the line with using (var www = new WWW(path.Replace("#", "%23"))):
    Code (CSharp):
    1. if (!File.Exists(path)) Debug.LogError("File doesn't exist");
     
    Last edited: Jun 21, 2018
  7. RenegadeNinjaNL

    RenegadeNinjaNL

    Joined:
    May 23, 2013
    Posts:
    22
    Yeah, that error message pops up saying 'File doesn't exist'.

    Hmm... maybe the file is being written to like you said, but I only send the file data over once it is complete.
     
  8. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    My guess would be that you start loading the gif before Unity is done moving it to that folder.
     
  9. RenegadeNinjaNL

    RenegadeNinjaNL

    Joined:
    May 23, 2013
    Posts:
    22
    I think I know what you mean, but I'm not a good enough programmer to be able to code that.

    But thanks anyway for helping me figure out what was causing the error.
     
  10. rr_7827

    rr_7827

    Joined:
    Feb 23, 2017
    Posts:
    4
    In 2018.1.5 it seems that an autostart, thread-decoded, looped gif only plays once. If you then select that same gif again in editor, it plays correctly looped.

    From the code it appears that _threadLoop will never be set true the first time a gif plays because _threadLoop only gets set if there's already a _decodeThread. Since _threadLoop gets passed to _gifDecoder.ReadNextFrame(_threadLoop), the decoder reaches the end of the stream, sees that "loop" is false, and doesn't called RewindReader(). The next Read() is still at the end of the stream, and so _status gets set to StatusFormatError. After that, the Player continues looping through frames, but the decoder remains in the StatusFormatError state, so the pixels remain on the final frame of the gif.

    Can you please advise what the correct workaround is?

    Thanks for the awesome asset! Other than this little snag, it's been a pleasure to use.
     
    Last edited: Jul 21, 2018
  11. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Thank you for the detailed description! This helps a lot in finding the cause. It appears you are correct. I must have broken this in a previous update. Does it also fail to loop when you enable buffering?

    Unfortunately I won’t be in the office again for another 2 weeks and haven’t got a laptop with me so I can’t test it myself.

    I am very sorry for the inconvenience caused.
     
    rr_7827 likes this.
  12. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    869
    Im interested in buying your player to play animated GIFS in WEBGL.

    Does the GIF have to be a pre existing file already built in the unity streaming folder, or can i download a random GIF from the web at runtime and play it?

    Does the rest of the game freeze while its playing the GIF?

    What if i download 5 or more different animated GIFS from the web at runtime, can it play all of them at the same time? How many can it play at once?

    Thanks
     
  13. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    The gif doesn’t need to be included in the build. You can either download it yourself and play it or just pass an url instead of a path to the gif and it will download it from an http source.

    The rest of the game will keep running while you play the gif. Simply add the gif player component to a game object and it will display the gif as a texture on it. You can use as many of these components at the same time as you like. See the YouTube movies in the first post of this thread on how this works.
     
  14. berkhulagu

    berkhulagu

    Joined:
    Sep 6, 2017
    Posts:
    11
    I needed to disable "Threaded decoder" in order to make the looping work in "UI Example". Apart from that, it is a great and a very easy to use library, great work. Kudos!
     
  15. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Thanks! I will be back again this Monday and fix the problem right away so the threaded option can be used again.
     
  16. thatscraigz

    thatscraigz

    Joined:
    Mar 27, 2015
    Posts:
    93
    Hi @Mareck I saw your note earlier about reading GIFS from different paths.

    Currently I store players GIFs in a folder in their 'My Documents/Mac Alternative' folder. Would I be able to read those in no problem?
     
  17. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    It currently only supports StreamingAssetsPath, PersistentDataPath and TemporaryCachePath since, for many build targets those are the only paths you have access to (this includes the most used build targets like iOS, Android and WebGL). Adjusting the gif player code to accept a full path for example isn't to hard if you need that functionality. If you want I can send you any changes that you should make for this to work.
     
  18. thatscraigz

    thatscraigz

    Joined:
    Mar 27, 2015
    Posts:
    93
    Gotcha :) yeah I'm using standalone so have a few folders outside those locations that I'm using.

    Thank you, I would love that extra functionality, definitely send it my way when you can! :)
     
  19. drunkbeatzdiggi

    drunkbeatzdiggi

    Joined:
    Sep 11, 2018
    Posts:
    9
    Hi @Mareck !

    Unfortunately the Gif Player is not working so well for me... I'm using Unity 2018.2.6f1 (64-bit) on Windows 8.

    Whenever I export a scene including the Animated Gif Player for WebGl, the Gifs do only play well if the Web-Gl files are saved on my harddrive and I launch them by clicking on the "index.html".

    However, once I upload the WebGl-files to my server, the Gifs do not play though. You only see a white screen. it seems that the links get broken once I upload them. Everything else in the unity project is working fine online.

    Another strange thing is that through all my uploading attempts sometimes one or two of the Gifs worked, while the others did not.

    Again, everything is working perfectly fine when I open the index.html offline with Firefox.

    Do you know that problem and do you know what could cause this/how I could fix it? I find it quite strange that the problems only exists online so I'm wondering if it might have to do with the uploading process (I'm using filezilla for that).


    Thanks,

    Moritz
     
  20. drunkbeatzdiggi

    drunkbeatzdiggi

    Joined:
    Sep 11, 2018
    Posts:
    9
    you can see the game here: www.drunkbeatz.com/gallery.html

    to get to the level with the gifs, you have to jump into the beer and then dive through both of the "open" signs.

    right now 4 of 5 gifs are working, and they all have the same settings...
     
  21. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Hi @drunkbeatzdiggi

    Hi!

    I just tried with the latest version and the mesh example included in the Gif Player asset and it seems to work here.

    I also just played through the first part and gotten to the space part. There are two white spaces where I assume the gifs must be shown.

    Are the two gifs that are not shown also the largest ones? I see that the two largest are quite big files. The largest even being 23 mb. Maybe you are running into some kind of memory limit here that prevents unity form loading them. You could increase memory available under publishing settings.

    Also: http://s739756619.online.de/StreamingAssets/tomaszkonczankowski 1.gif won't show in the preview tab in chrome network info for that page while the others do. Maybe something is wrong with the gif. You could try re-encoding it using a site like https://ezgif.com/optimize
     
  22. drunkbeatzdiggi

    drunkbeatzdiggi

    Joined:
    Sep 11, 2018
    Posts:
    9
    Hi Mareck and thanks for your quick response!

    Strangely, when I opened up the game online today, all of the Gifs were working for me in both Firefox and chrome. I dont know why this changed overnight, might have to do with the memory. I still want to do what you proposed though and smaller the Gifs so that the project file is smaller but now I have another new issue:

    So far I was working with the project that a friend designed for me, he was implementing the Gifs using and telling me about your Animated Gif player. I could play the Gifs in my project without a problem even without having the player installed myself, but then decided to buy your Animated Gif player (also to support ;P) and installed it two days ago - but since then, the Gifs I apply to the cubes do not show anymore. Neither in the editor mode nor in the game mode.

    Do you know what could cause this? Can I somehow re-install the player?

    Would be great if you let me know, I would love to finish the finetuning and publish it ;P

    Thanks again!


     
  23. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Thank you for the support!

    It is very strange that they don't show up any more. Do they show up at least in the component where you can select the gif?
     
  24. drunkbeatzdiggi

    drunkbeatzdiggi

    Joined:
    Sep 11, 2018
    Posts:
    9
    Yes they show up in the component and I can also play them there, but they are not visible in the game nor in the editor...

     
  25. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Can you email me a copy of one of the gifs so that I can test it? Please send it to support@oldmoatgames.com
     
  26. drunkbeatzdiggi

    drunkbeatzdiggi

    Joined:
    Sep 11, 2018
    Posts:
    9
    Hi Mareck!

    Thanks for the offer! I just realized it had to do mostly with the Albedo and Emission settings, they were too dark in the Main Maps tab so that the cubes the Gifs are supposed to be seen on just showed a black screen. I guess I changed the settings at some point and thought the re-installation had something to do with - but anyway, its working again and I guess I kinda messed it up ;P

    Thanks for all the help! I hope that it will all work smoothly now. I also smallered the Gifs as u proposed, so that the browsers might handle the Gifs better.

    Have a good day!
     
  27. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    I am glad you got it all working now. Please don't hesitate to contact me again if you are having any problems with the asset!
     
  28. drunkbeatzdiggi

    drunkbeatzdiggi

    Joined:
    Sep 11, 2018
    Posts:
    9

    Hi,

    thanks for the offer - because actually some problems with the asset are back ;P

    I did downsize all the GIFs now (they are all smaller than 5MB) and made the whole project a little smaller.

    But the problem with the GIFs not being displayed properly online is still there. Again, the GIFs do play perfectly well once I load the WebGL-file from my harddrive. But when uploaded to a server and accessed via the internet the problem is the same: The first time I enter the space-level, only one of the GIFs is playing, the other Gif-Cubes do not show any Gifs and remain empty.

    The funny thing is: When I reload the gallery in the browser and enter the space level for the second time, all of the GIFs are playing. I tried it with both in Firefoy and Chrome and both browsers react that way - first time entering, no or only one GIF playing, second time entering all of the GIFs are playing.

    So I'm assuming it must have to do something with the cache? That some of the information is not being loaded immediately or that it can not be accessed directly? Do you know how that could be solved or any workaround that I could try?

    I put the GIFs in the Streaming Assets folder within unity. Might that cause the problem?

    Or could it also have something to do with the internet? Is it the same for you? I put the new version online under www.drunkbeatz.com/gallery.html (again, to enter the space level its to jump in the beer, and then diving into the "open" signs") if you want to check how it reacts online...


    Thanks!

    Moritz
     
  29. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    For me all the gifs loaded the first time. 2 of them are glitching a bit though. The bottom edge is flickering a bit on them I don't think that is related to the gif player though. Maybe there is another object too closely below them or something?

    It could be something else altogether btw. Maybe an adblocker or virus scanner that is blocking them. You could check if the gif is recorded correctly by checking the Width and Height property after you have started playback.
     
  30. Kiv

    Kiv

    Joined:
    Nov 3, 2013
    Posts:
    3
    I'm encountering a bug playing some GIFs where the bottom of the image is just black. This happens with a local file and shows up in the Inspector as well as the live game. Only some of the frames have this issue.

    Attached is a GIF that exhibits this problem, with a screenshot of how it appears in game.



    Untitled.png

    This is in v1.13.5 of the asset, Unity 2018.2.7f1, Windows 7.

    Thanks in advance for your help!
     
  31. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Hi!

    The kinds of defects are usually caused by an encoding method that is not supported by the gif player. I chose not to support this method because it is rarely used and it requires significantly more memory and cpu usage when decoding on mobile. Luckily the fix is simple: Just recode the gif using a tool like: https://ezgif.com/optimize . Just select resize and enter the same dimensions. I have included a fixed version of your gif.
     

    Attached Files:

  32. Kiv

    Kiv

    Joined:
    Nov 3, 2013
    Posts:
    3
    Thanks for your reply. I agree that re-encoding will work for a local file, but for my use case I also need to dynamically load GIFs from the GIPHY API, and the only format they use is GIF 89a.

    Would you consider implementing at least partial support for GIF 89a?

    I understand it would be extra work, but the player is advertised on the asset store as playing GIFs, with no mention of this restriction. So I feel a bit misled that only the older format of GIF is usable.
     
  33. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Only the disposal 3 method is not supported of the 89a spec by the player. To be honest, the only time I ran into this disposal method myself was while developing the player and was looking for a gif that explicity demonstrated this disposal method.

    I will take a look at the code to see if it can be added without changing to much performance loss. Probably as an advanced options toggle.
     
  34. Kiv

    Kiv

    Joined:
    Nov 3, 2013
    Posts:
    3
    Thanks, that would be great!

    Here are two more GIFs from GIPHY that don't render correctly in the player.

    This one might have the same issue as the previously posted one:

    3oz8xH46dD1DSx3vNK.gif

    This one doesn't play at all in the inspector, maybe related to the fact that it has only two frames? When I play it in the live game, the frames toggle very quickly, much faster than they should.

    Hc8PMCBjo9BXa.gif
     
  35. david_osayande

    david_osayande

    Joined:
    Jun 19, 2018
    Posts:
    4
    Hello,

    I purchased your asset and it works well within unity. However, when exported to WebGL (hosted on itch.io) there is usually a long delay with a white screen before the gifs start to play. Also, randomly today, There were a few instances where the gif never played and was simply a white screen the entire time or a static image of one frame within the gif. Not an issue when played on my local server. Gifs are all in streaming assets folder. Sizes range from 5 - 15MB. Gifs are dynamically called during runtime via the parh/url option (using the file name of the gif).

    Also, there was another instance where the prior gif remained for a little while before the next one finallly showed up. How do I fix this? Happy to provide whatever additional info is necessary. Sounds like there was someone with a similar issue earlier in this thread - but the issue wasn’t resolved here.
     
  36. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Hi!

    This could be WebGL running out of memory. You can trying increasing the amount in the build settings. Another possible cause is that the gif is blocked by an ad blocker.
     
  37. david_osayande

    david_osayande

    Joined:
    Jun 19, 2018
    Posts:
    4
    interesting.

    1) Any idea how much I would need to increase the memory? And is there a workaround for the potential adblocker issue?

    2) Perhaps giving it a play would help. I messaged you a link to the game.

    3) also, in unity, I keep getting a caution error that saying that animatedgifplayer is not designed for webgl output. any idea what that is about? could it be related to the issue?

    4) also, would optimizing my gifs help at all?
     
    Last edited: Oct 26, 2018
  38. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    I would just increase memory by a very large amount just to see if that solves it. Then try lower amounts until it stops working again.

    What is the caution message exactly? This is probably the warning for the threaded decoding which is not supported by WebGL. You can just ignore that, the player will automatically disable threading for the build if you have it enabled.

    I tried the game and the gifs are quite large. Since they are displayed like a thumbnail I would resize them anyway to reduce load times for your players. I always use https://ezgif.com for resizing and optimizing. I am pretty sure this will solve the problem for you.
     
  39. david_osayande

    david_osayande

    Joined:
    Jun 19, 2018
    Posts:
    4
    Did you mean large in physical size or file size? They are around 5MB - 15MB each. What should I aim for with resizing given my purposes (regarding file size)? And should I shrink the physical size as well to help with the issue?

    And do you no longer think that an adblocker might be at play as well? I did notice the issue seems to be worse when playing via the WiFi at academic medical centers - does that suggest an ad blocker issue as well? Or can that also be explained by the large file sizes?

    Thank you so much for the amazing responsiveness by the way. You have been BY FAR the most helpful developer of all the unity assets I’ve purchased since starting. Amazing support!!
     
  40. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    The largest I saw was 25mb in size. I don't know if you reuse them showing larger but it seems much for a thumbnail sized gif. Considering the size you display them at I would try to reduce the size to 200 pixels or a few mbs. The process of resizing is really easy with the site I posted and I think that will fix it.

    Adblocker doesn't seem the cause of the problem when I ran it.
     
  41. david_osayande

    david_osayande

    Joined:
    Jun 19, 2018
    Posts:
    4
    So I did what you said and shrunk the gifs. They are each 200 pixels wide and >200 pixels tall. I think the largest is maybe 3MB. I TRIED optimizing them as well using the ezgif website. However, something strange happened when I did that. Although the gif I download would look perfectly find, when the animated gif player played the optimized images in Unity, it would get quite distorted with flickering. So I just left it alone at 200 pixels - which was already a significant size decrease. Most gifs were find, but a few had a similar flickering problem. Seems to be something specific to the gifplayer since the gifs play perfectly fine in my computer. This issue occurs both within Unity and webgl.

    Regarding teh white flickering, it's still there as well - all though much less pronounced. Anything else I can do? I am indeed only using the images as thumbnails - but resizing anymore starts to cause distortion that really affects the quality of the picture.

    (When you check the game, you'll notice the questions near the very end of the game with the following text ("which of the following digital substraction angiograms illustrates...")

    Thank you!
     
  42. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    Can you post one of the gif that have this problem? I am working on a fix in the decoder that should solve a problem with some gifs. Sometimes the flickering can also be caused by placing an object on the same z position in 2-d. This goes for every texture, not just textures created by the gif player.
     
  43. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    @Kiv and @david_osayande

    A new version (1.14.0) has been released in the assetstore that fixes some decoding issues and has an extra compatibility mode to enable playback for more GIF types.
     
    Last edited: Oct 31, 2018
  44. unoniceday

    unoniceday

    Joined:
    Nov 19, 2016
    Posts:
    4
    hi In oder to build my gif player
    I change the part of code like this
    Code (CSharp):
    1. public int CurrentFrameNumber { get; set; } // The current frame we are at
    and I will select frame by myself , this work will but

    I use this code for every Input.GetMouseButtonDown

    Code (CSharp):
    1.  public void SetFace(string faceName)
    2.     {
    3.         AnimatedGifPlayer.FileName = "UGIF/"+faceName+".gif";
    4.      
    5.         AnimatedGifPlayer.AutoPlay = false;
    6.  
    7.         AnimatedGifPlayer.OnReady += OnGifLoaded;
    8.      
    9.         AnimatedGifPlayer.OnLoadError += OnGifLoadError;
    10.      
    11.         AnimatedGifPlayer.Init();
    12.      
    13.     }


    Code (CSharp):
    1.  private void OnGifLoaded()
    2.     {
    3.      
    4.         AnimatedGifPlayer.Play();
    5.         RemoveEvent();
    6.     }
    and my "Animated Gif Player" setting is ((see picture))

    and I found two problem (maybe bug?)

    1. quickly click Input.Getmousebuttondown to SetFace("gifName") , It would stop in a frame , and i saw "Animated Gif Player" Inspector ,it state is play not pause, whether it can't reload gif too fast?

    2. whether "buffer all frame" and "cache frames" too much memory ? how can i improve it

    I use 1024*600 pixel 25frame Gif .
    if I don't want to change 1024*600 pixel , can i clean buffer or cache and reload it when I change Scene ?

    I saw it use about 280mb in normal but change Gif many time it will become 4XXmb (or just memoryProfiler
    measuring error I don't know)

    thank for your help ! I'm so appreciate it .
     

    Attached Files:

  45. Mareck

    Mareck

    Joined:
    Aug 13, 2014
    Posts:
    77
    I am not sure I understand everything.

    Be sure to give the player enough time to load the gif. This can take a few frames. The code wasn't really tested for a use case where you restart loading a gif when the first hasn't completed loading yet.

    For large gifs with a high resolution and lots a frames the memory usage can be quite large because each frame is stored separately and uncompressed in a byte array. You lose any compression done by the gif (that means the LZW compression within each frame and the skipping of unchanged parts between frames). The reason for this is that, when cached, I want to be able to upload the frame to a texture with as little CPU usage as possible. For small gifs this is no problem, but for large GIFs I would advise not to use caching or buffering to reduce memory usage.

    As for memory usage increasing when switching GIFs: there was a bug that caused a memory leak when siwtching GIFs, but this has been fixed. Are you seeing an increase in memory usage each time you load another GIF?
     
  46. unoniceday

    unoniceday

    Joined:
    Nov 19, 2016
    Posts:
    4
    ok it fixed when i use EndDecodeThread() in onDisable() that cause memory leak

    and i have another problem is I didn't know it's my device Gpu too low or other reason

    when switching GIFs about 20~30 times , Unity will shotdown and report "Graphics buffer count : 3"
    it's occur when i use "buffer" and "cached" , it is a bug ?
     
  47. AugmentedMarketer

    AugmentedMarketer

    Joined:
    Jun 28, 2017
    Posts:
    2
    Hello!,

    So I have two questions for you. First off this currently crashes my app on IOS but works fine on andriod, I am loading the gif through a link that is passed to it after the app starts in an augmented reality environment. It works fine if I disable the component but as soon as I try and load it the app crashes immediately.

    Secondly during the process of loading the app through the link I get this ugly red question mark, Is there any way to replace it?

    Otherwise thank you for the great plugin I hope you can help!
     
  48. robertoranon

    robertoranon

    Joined:
    Feb 21, 2018
    Posts:
    16
    hello! I just purchased the asset but I've a problem: when I select the GIF in the inspector, I get the following errors:

    Code (CSharp):
    1. EndLayoutGroup: BeginLayoutGroup must be called first.
    2. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    and

    Code (CSharp):
    1. EndLayoutGroup: BeginLayoutGroup must be called first.
    2. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    I'm on a Mac, using unity 2018.2.16.f1
     
  49. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    869
    Hello,

    Im using your animated GIF player, it works great, but i notice one thing you can do to improve performance.

    Right now i have a VERY LARGE GIF that has no animation, its just a gif with a single image, but the gif player seems to be playing that same single image over and over again wasting CPU because the image is really LARGE,
    I know this is happening because the game is very slow, and as soon as i uncheck LOOP in the animated gif player the game speeds up! (its a very large gif)

    Is there a way for you to check if there is only one frame in the GIF (or just one picture in the animation) and then just display it once (even with looping turned on), instead of wasting CPU displaying that one image over and over again?

    I already fixed it myself by changing your code, it works much better!

    CurrentFrameNumber = 0;
    if (!Loop || (_gifDecoder.NumberOfFrames<2)) { <<<<<<------
    // Stop playback if not looping
    Pause();
    return;
    }


    Thanks
     
    Last edited: Mar 7, 2019
    MrLucid72 likes this.
  50. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    902
    Is this still supported in Unity 2018.3+?

    ^ And is it true these frames are not cached, looking at that question above? I thought after 1st loop it should be relatively low cpu stress.
     
    Last edited: Mar 24, 2019