Issues with imported file and canvas (Time Offset and Speed)

Synfig crashes when trying to import a file into itself.

To reproduce:

Create a file
Save the file
Within the same file, Go to file import and select the same file.
Synfig crashes

Expected
Do not allow to import a file into itself (Display a message not to import the file into itself)

I know that it is a stupid idea to import a file into itself. I just wanted to see what happens (I thought I would get infinite canvas within each other :sweat_smile:)

5 Likes

lol, I see you have a lot of time on your hands. xD

3 Likes

I thought you did it by mistake lol

1 Like

Feature for creating precomp and using it in Synfig is great but it has some issues and I did figure out some workarounds too.

The problem is with Time Offset
Normally, I expected that when we put an offset of 10f all the keyframes of that canvas/group should move 10f ahead, but Synfig moves it backward. So the workaround is simple just put -10f and it will move it 10 frames forward. This is not an issue at all but I do think that offset should move it in forward time.

Another issue is also related to Time offset.

When nested precomp/canvas, time offset stops working.

For example, I have some animation in file comp1.sifz,
then I import that into “comp2.sifz” and so on till comp5.sifz. Now, let “comp5.sifz” have 2 “comp4.sifz”, so when I change the time offset of one of the “comp4.sifz” nothing occurs. But if I disable one of the 2 “comp4.sifz” and the time offset of the other is set to for example 10f then it will work. Initially, I thought that this was a problem with the preview. I tried to render the frame but it doesn’t do anything different.

So a workaround for this is every time you import a file more than once create a new directory and copy all the files below that level for example you want “comp4.sifz” twice in your “comp5.sifz”. The copy “comp4.sifz” with all its inner child precomps i.e. comp1, comp2, comp3. Into a separate folder and then import them into “comp5.sifz”. By doing this the time offset will work, but this completely dismisses the use of precomps in the first place. So for example I need to edit some small animation in “comp1.sifz”. I have to go to all comp1 in all folder to achieve that.

(Also I have tried making comp1 common and then have comp2, comp3, comp4 into different directory but somehow the renderer detects them as same thing and in fact they are same thing, and the time offset doesn’t work )

Take a look at the file from

Everything works fine in that example.
Here is the time offset doesn’t work, open comp5 and try disable a layer and changing the offset.

CompMagic (TimeOffset).zip (12.6 KB)

Please take a look at Duplicate layer :slight_smile: It can help you to quadruplicate the rectangle corner you animated, by using its exported value named “Index” to rotate the group.

Regarding the time offset, I’ll try to take a look later. If I or anyone else don’t answer you, please file the issue on our Github repository.

:stuck_out_tongue:

3 Likes

Fixed on master branch :slight_smile: [Studio] Fixed a crash when trying to import a file into itself by rodolforg ¡ Pull Request #2239 ¡ synfig/synfig ¡ GitHub

2 Likes

Something like that :smile:

@rodolforg anything about the Time Offset issue?

I think the time offset feature works as it was intended.
Rescale Animations - Synfig Animation Studio

I don’t understand.

The issue is Time Offset parameter of Group layer stops working if a file(B.sif) has imported other file (A.sif) more than once, then Time Offset stops working. Also deactivating a layer will make a time offset work (if you disable layer at the top, then the time offset will work for layer below it, if both the layers are activated the time offset of the topmost level is only considered and offset of other layers is ignored).

Steps to reproduce:
Create a file with basic animation (A.sif)
Import in another file (B.sif), import again the same file (A.sif) or duplicate the imported layer.
Change time offset of imported layer groups.

Try deactivating layers (you may need to move time cursor to see the effect, sometimes it don’t update the canvas properly), try changing the level of layers.

I hope this makes it clear.
Also you can check this file

I suppose it can be done via exported canvas. But I didn’t try it.

It works ok when only one instance is imported. If you import something twice (or more), if you change “time offset” or “speed” it’ll affect others too.

I just checked. Not so easy to solve :frowning: As it is now, AFAIK Synfig loads a Canvas only once and every import refers to same Canvas object (it’s logical and ok for memory saving).
However, Layer_PasteCanvas::set_time_vfunc(IndependentContext context, Time time)const will then
change them all (as they are actually a single one) together.
We need to think about it to find a good solution… @ice0 @KonstantinDmitriev @Keyikedalube

void
Layer_PasteCanvas::set_time_vfunc(IndependentContext context, Time time)const
{
	context.set_time(time);

	if (!sub_canvas)
		return;
	if (depth == MAX_DEPTH)
		return;
	depth_counter counter(depth);

	Real time_dilation = param_time_dilation.get(Real());
	Time time_offset = param_time_offset.get(Time());
	sub_canvas->set_time(time*time_dilation + time_offset);
}

I found a workaround: export the canvas of (at least) one of imported canvas :wink:

  1. Import a sif file
  2. Import the same sif file of step 1
  3. Select one of the imported SIF in Layer Panel
  4. In Parameter Panel, right-click on canvas parameter and select Export Value
  5. Type a name to export it

VoilĂ .
(I didn’t test it too much though)

Doing this is the same as the Embed Layer option (by right-clicking the imported layer).

But it dismisses the main advantage of importing a canvas/file that is I can edit the animation in one file and then use it in many other animations, many times.

Embedding a Layer will just no longer give that advantage, I need to go to each file that has imported the animation and edit them individually, if I would like make changes.

I did try it with exported canvas, the time offset and speed don’t work.

To reproduce:

  1. Create an animation, group the animation (Group1)
  2. Export the canvas of Group1 (canvas1)
  3. Create a group and change its canvas to canvas1
  4. Change the time offset/speed

The time offset and speed doesn’t work. So this problem is not only on imported layers but also for exported canvas.

I think this is a serious issue to fix.

Synfig has no concept of instantiation yet. :confused:
Implementing it could take a time because it could break a lot of (hidden) stuff, as we don’t have enough active people with a long-time experience with such inner code. I started to contribute in the middle of 2019. I still don’t know many things of its core.

So that’s the final code statement that’s executed when OP duplicates (or imports) his comp layer…?

If so OP already kinda correctly answered his issue:

Because his recent time offset modification to one of comp4’s canvas (actually layer) group ie., -20f is also applied for the duplicated second comp4 group layer since both of these two layer groups recursively import and point to the same child canvases instead of OP’s assumption of working on isolated canvases. That’s my logical understanding why time offset isn’t working as expected.

However, the waypoints placement displayed on the timebar for second comp4’s group time offset 0f is misleading.

BTW, I don’t know anything about precomp stuff commented above so I had to look up what that keyword means in animation. Found this awesome YouTube video https://www.youtube.com/watch?v=9Fv3XVdTOXM and am totally amazed by how complex and impressive animation precomps can do!

Precomposing or precomps is actually a separate feature in After Effects where canvases are actually isolated within the same file and sadly Synfig doesn’t have that feature (at least googling “Synfig precomp” didn’t lead me anywhere). Just duplicating the imported layer doesn’t create a separate canvas. That duplicated layer too is rendered on the same canvas so others suggestion for exporting a sub-canvas is a viable solution I think.

Anyway @veermetri05 impressive work :wink: I like how you creatively replicated the precomps behavior by importing each incrementing comp*.sifz files as layers. Sorry, I can’t help much because I’m a self-taught animator and your work is waaaaay beyond my skillset.

@veermetri05 did you try saving, closing, and reopening the file again after step 4? I did that and time offset changes were reflected correctly on my end.

According to Synfig wiki on Time offset parameter:

“It brings the animation of the entire contents of the referenced layer forward by the given value. Using negative values it is possible to delay the grouped layer, too.”

Fix for this issue just uploaded by @rodolforg a few hours ago.

1 Like

I’ve noticed that when I export a canvas and then duplicate that exported canvas group and try to give different time offset values to the these group, those groups act as if they have the same offset.