Animation restrictions?

General TRichView support forum. Please post your questions here
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Animation restrictions?

Post by Sega-Zero »

Are there any restrictions to animators? Wrote my own gif implementation and have noticed, that sometimes (espesially when there are a lot of animations are inside rv and while scrolling it) animation dissapears (just a rv background is drawing, like animator is skipped). That is definetly not a bug of my lib, have checked everything. RichView just don't paint it for some reason i can't understand...

So, is there any way to force animator painting?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Animations is supported only for the following gif implementations:
-TGifImage by Anders Melander,
- TGifImage included in Delphi 2007-2008
- TJvGifImage from JVCL.
Did you implement a special TRichView animator like it was implemented for these classes? Animators for these classes are in units: RVGifAnimate, RVGifAnimate2007, RVJvGifAnimate.
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

yes. I did like in TRVGifImageAnimator. At what cases animator cannot be drawn?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

There is a limit on animators count (const RVMaxAnimations: Integer = 100000), but I doubt you exceed it.
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

no, i've tested it on 50k gifs. But it is just to reproduce the bug. it appears even on small count of animations, but it is hard to catch it then. This is happening after some hours of intensive work with adding/removing gifs.

The strangiest thing is that gif appears again when animation cycle starts from the beginning. It's kinda mystery for me
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Try the same test with another gif implementation
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

exactly the same test is impossible. too many GDI leaks. thats the reason i wrote my lib for. TGifImage brakes application in a few scrolls of whole area with EOuOfMemory. TjvGifImage even less.

could you please tell me how TAnimator work and in what cases it cannot be drawn?

P.S. working on Delphi 7
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In my test, there were no GDI leaks with TGifImage.
And GDI resources are minimally used when animations are inserted in TRichView, because TRichView animates them itself, not using their built-in animation features.
What version of TRichView do you use? May be you use older version, which used much more resources for animation, and had much smaller default value of RVMaxAnimations?
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

using the last version. gdi leaks are present - scroll the whole area (by dragging vertical scrollbar with mouse) fast up and down - in a few iterations it will fall (gdi leaks gets from somewhere inside TGifImage, while extracting frame bitmap). That is not accepteable for me...
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

forgot to say, i don't think this is a limitation problem - animators are not skipped at the end. They skipped randomly within drawing area
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I cannot reproduce the problem with TGifImage.
I created a test project:

Code: Select all

var i: Integer;
    gif1, gif2: TGifImage;
begin
  gif1 := TGifImage.Create;
  gif1.LoadFromFile('kengu.gif');
  for i := 1 to 20000 do begin
    gif2 := TGifImage.Create;
    gif2.Assign(gif1);
    RichView1.AddPictureEx('', gif2, 0, rvvaBaseLine);
  end;
  gif1.Free;
  RichView1.Format;
end;
If animation is turned on (RVGifAnimate is included in the project, and RichView1.AnimationMode = rvaniOnFormat), I can scroll back and forth without problems. This is because animation is handled by TRichView, only memory for the current frame and only for visible animations are allocated.
If animation is turned off, the program really fails. But it's not because leaks, but because too many objects used. In this mode, images are shown using Canvas.Draw method. On each repainting, TGifImage displays a new frame (and creates a new bitmap for it). When I scroll back and forth, more and more frames are displayed, and more and more bitmaps are created, until the application fails. But again, it happens only if animation is turned off.

The last version of TRichView is 11.0.1 (11.0 is also ok).

Sorry, I do not know why your animators are not shown. Probably something is wrong with them, because I cannot reproduce this problem with TGifImage.
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

try this code. this will reproduce gdi leak bug easyly (especially when set the size of a window larger so the drawing area could be wider):

Code: Select all

var i: Integer; 
    gif1, gif2: TGifImage; 
begin 
  gif1 := TGifImage.Create; 
  gif1.LoadFromFile('kengu.gif'); 
  for i := 1 to 20000 do begin 
    gif2 := TGifImage.Create; 
    gif2.Assign(gif1); 
    RichView1.AddPictureEx('', gif2, -1, rvvaBaseLine); 
  end; 
  gif1.Free; 
  RichView1.Format; 
end;
try to scroll it now.

But my problem is not a gdi leak (that is not a problem for me now). The problem is animation dissapearing...
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Well, you are right. While bitmaps were ok (used minimally), there is one more type of resource that is accumulated for each image: palettes.
I opened RVGifAnimate.pas, and added after
TGifSubImageHack(gif.Images[FrameIndex]).FreeMask:

Code: Select all

      TGifSubImageHack(gif.Images[FrameIndex]).Palette := 0;
      gif.Palette := 0;
I am not sure if this change is harmless, but after it the problem is gone.

Sorry, I do not know why your images disappearing.
I cannot reproduce this problem with TGifImage.
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

sorry to dissapoint you, but your patch isn't working. show a gif with at least 15 frames, and scroll content by mouse-scroll. And take a look at task manager and the process GDI objects parameter. TGifImage by Anders Melanders is really buggy :)

Maybe the source of animator will be more helpful? Will upload a video of animation dissapearing in a few minutes to demonstrate how this is happening
Sega-Zero
Posts: 19
Joined: Thu Nov 22, 2007 9:11 pm

Post by Sega-Zero »

here is the source of animator.
here is the video that describes the effect.

As you can see at the video, I've set the background of gif manually to the green color. (Instead of

Code: Select all

RVData.GetItemBackground(RVData.DrawItems[item.DrawItemNo].ItemNo, R, True,
    FBackColor, bmpsrc, UseSrcBitmap);

  gif.BackGroundColor := FBackColor;
  if UseSrcBitmap then
    gif.BackGroundBitmap := bmpsrc;
i've commented that block and set

Code: Select all

gif.BackGroundColor := clGreen;
)

But sometimes, randomly, instead of drawing gif RV shows empty rect. That is definetly not a bug of the lib. But it could be wrong animator code. Maybe i lost something important. Something that tells RV not to draw it...
Post Reply