You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash when adding converters to 'list' type (splines) #1731
Issue description
In some specific cases Synfig can no longer process converters on splines parameters. For example, we have two shapes: rectangle and circle. We want a dot to follow 'rectangle' spline and then half-through the animation jump to 'circle' shape. It's easy to achieve using 'Spline Vertex' converter, we convert origin of a dot and then convert spline parameter to a switch and that's it.
And this scheme works in Synfig 1.0.2 but doesn't in all newer versions starting from 1.2.x.
To reproduce
Create any layer with 'Origin' parameter, let's say Circle.
Convert 'Origin' to 'Spline Vertex'.
Convert 'Spline' parameter of 'Spline Vertex' converter to 'Switch' and Synfig crashes.
It seems to be a global issue and probably affect other converters that can work with splines such as 'Time Loop' for instance but I haven't checked that. Additionally, I attached an example file of the animation described above (it crashes on loading). VertexListBug.zip
I started learning C++ not so long ago and was trying to solve this issue because it hinders my workflow. I was able to solve it, but not entirely sure I did it correctly.
Please check out this commit: Svarov-RZM@baae32c
I don't know why, but for some reason ValueNode_BLineCalcVertex::operator()(Time t)const in valuenode_blinecalcvertex.cpp was trying to access its own class through pointer (-> operator) instead of accessing it directly (. operator). In short, there were some unnecessary pointer magic and in some cases it would crash in assert call.
I reworked it to use direct access to ValueNode_BLineCalcVertex class and program doesn't crash anymore. I also did some testing and didn't find any regressions.
@rodolforg@ice0 what's your opinion on this? Is it appropriate fix?
I haven't dug deep on ValueNodes, so this is an assumption. But as I see, when you convert the Spline parameter to Switch, it cannot convert it to the ValueNode_BLine class. The reason it wants to cast is just to check if the spline is looped (Bline is a spline in this context). And it fails because the conversion failed. In this situation, we can assume that the shape not looped.
So here you need to check if the looped parameter is change animation behavior or not. If not, here's how I suggest to change the code:
const ValueBase::List bline = (*bline_)(t).get_list();
handle<ValueNode_BLine> bline_value_node( handle<ValueNode_BLine>::cast_dynamic(bline_) );
//assert(bline_value_node);
// For classes that cannot be converted to ValueNode_BLine, we assume they are not looped
const bool looped = bline_value_node ? bline_value_node->get_loop() : false;
The reason it wants to cast is just to check if the spline is looped
As I understand, there's no need for that, because loop parameter is available from ValueBase class, which we can access directly (just like we can access get_list from dereferencing *bline_ pointer).
So here you need to check if the looped parameter is change animation behavior or not
Yes, it does change the animation as expected. I compared against 1.0.2 and 1.2.2 versions.
I am going to run some more tests on weekends and if nothing pop up, I'll send a pull request.
The reason it wants to cast is just to check if the spline is looped
As I understand, there's no need for that, because loop parameter is available from ValueBase class, which we can access directly (just like we can access get_list from dereferencing *bline_ pointer).
To get ValueBase from ValueNode, you pass time to it. Thus, the possible loop value can change over time (and may be this will be more correct behavior). On the other hand, any solution would be better than a crash )
If you're correct in the solution, other two files valuenode_blinecalc* should be correct too
You're right! The same crash happens in 'Spline Tangent' and 'Spline Width'. The 'Spline Width' converter is broken even more, it doesn't allow you to make conversion, throws an error on attempt such as this:
Although, it does allow conversion in 1.2.2 version, so regression was introduced recently.
Anyway, are you able to switch the spline for the circle origin without crashing?
Yes, of course, I stated above that my commit solves the issue.
To get ValueBase from ValueNode, you pass time to it. Thus, the possible loop value can change over time (and may be this will be more correct behavior).
Could be probably done in the future, but currently GUI doesn't allow you to animate internal 'loop' parameter. For example, if you enter 'animation' mode, change time to 1s and then click 'Unloop' on any slpine it won't create a waypoint, but simply change parameter for the whole animation.
I sent a pull request. I propose to merge it, wait for regression tests to complete (synfig-tests-regressions) and if everything is alright then we can apply this fix for 'Spline Tangent' and 'Spline Width' converters.
Activity
rodolforg commentedon Oct 2, 2020
Confirmed :(
Fix crash in Spline Vertex converter (synfig#1731)
Svarov-RZM commentedon Oct 22, 2020
I started learning C++ not so long ago and was trying to solve this issue because it hinders my workflow. I was able to solve it, but not entirely sure I did it correctly.
Please check out this commit: Svarov-RZM@baae32c
I don't know why, but for some reason ValueNode_BLineCalcVertex::operator()(Time t)const in valuenode_blinecalcvertex.cpp was trying to access its own class through pointer (
->operator) instead of accessing it directly (.operator). In short, there were some unnecessary pointer magic and in some cases it would crash inassertcall.I reworked it to use direct access to ValueNode_BLineCalcVertex class and program doesn't crash anymore. I also did some testing and didn't find any regressions.
@rodolforg @ice0 what's your opinion on this? Is it appropriate fix?
ice0 commentedon Oct 23, 2020
Hi! Thanks for the investigating the problem.
I haven't dug deep on ValueNodes, so this is an assumption. But as I see, when you convert the Spline parameter to Switch, it cannot convert it to the
ValueNode_BLineclass. The reason it wants to cast is just to check if the spline is looped (Bline is a spline in this context). And it fails because the conversion failed. In this situation, we can assume that the shape not looped.So here you need to check if the looped parameter is change animation behavior or not. If not, here's how I suggest to change the code:
Svarov-RZM commentedon Oct 23, 2020
As I understand, there's no need for that, because
loopparameter is available from ValueBase class, which we can access directly (just like we can accessget_listfrom dereferencing *bline_ pointer).Yes, it does change the animation as expected. I compared against 1.0.2 and 1.2.2 versions.
I am going to run some more tests on weekends and if nothing pop up, I'll send a pull request.
rodolforg commentedon Oct 23, 2020
I checked the log history of this file:
There are a couple of changes after v.1.0.2:
I'll try to
git bisectit, if the first one is not the culprit.@Svarov-RZM thank you for investigate it! If you're correct in the solution, other two files valuenode_blinecalc* should be correct too.
rodolforg commentedon Oct 24, 2020
Argh, how horrible was building Synfig in those old days.
I give up lol
Anyway, are you able to switch the spline for the circle origin without crashing?
ice0 commentedon Oct 24, 2020
To get
ValueBasefromValueNode, you pass time to it. Thus, the possibleloopvalue can change over time (and may be this will be more correct behavior). On the other hand, any solution would be better than a crash )Fix crash in Spline Vertex converter (synfig#1731)
Svarov-RZM commentedon Oct 24, 2020
You're right! The same crash happens in 'Spline Tangent' and 'Spline Width'. The 'Spline Width' converter is broken even more, it doesn't allow you to make conversion, throws an error on attempt such as this:

Although, it does allow conversion in 1.2.2 version, so regression was introduced recently.
Yes, of course, I stated above that my commit solves the issue.
Could be probably done in the future, but currently GUI doesn't allow you to animate internal 'loop' parameter. For example, if you enter 'animation' mode, change time to 1s and then click 'Unloop' on any slpine it won't create a waypoint, but simply change parameter for the whole animation.
I sent a pull request. I propose to merge it, wait for regression tests to complete (synfig-tests-regressions) and if everything is alright then we can apply this fix for 'Spline Tangent' and 'Spline Width' converters.
Fix crash in Spline Vertex converter (#1731)
Fix crash in Spline Vertex converter (#1731)
Fix crash in Spline Vertex converter (#1731)
Merge PR#1890: Fix crash in Spline Width and return of improper type …
rodolforg commentedon May 9, 2021
This issue is already fixed in v1.4.1.
Fix crash in Spline Width and return of improper type in Spline conve…
Fix crash in Spline Width and return of improper type in Spline conve…
Fix crash in Spline Width and return of improper type in Spline conve…
Fix crash in Spline Width and return of improper type in Spline conve…
Fix crash in Spline Width and return of improper type in Spline conve…
morevnaproject commentedon Jul 30, 2021
The fix is shipped in Synfig Studio version 1.4.2 - https://www.synfig.org/2021/07/29/synfig-studio-1-4-2-released/
Fix crash in Spline Vertex converter (synfig#1731)
Fix crash in Spline Width and return of improper type in Spline conve…
Fix crash in Spline Vertex converter (synfig#1731)
Fix crash in Spline Width and return of improper type in Spline conve…