View Issue Details

IDProjectCategoryView StatusLast Update
0006607ardourbugspublic2020-04-19 20:17
Reporterdeva Assigned Tox42  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version4.X git (version in description) 
Summary0006607: lv2_plugin _impl->state not correctly set after project load.
DescriptionArdour version: 4.2-414-g0613b75

I added the following printfs to libs/ardour/lv2_plugin.cc: 1015:
-----------
if (!_impl->state || !lilv_state_equals(state, _impl->state)) {
    printf("State changed %p\n", _impl->state);
    lilv_state_save(_world.world,
                    _uri_map.urid_map(),
                    _uri_map.urid_unmap(),
                    state,
                    NULL,
                    new_dir.c_str(),
                    "state.ttl");

    lilv_state_free(_impl->state);
    _impl->state = state;
} else {
    printf("State didn't change\n");
    // State is identical, decrement version and nuke directory
    lilv_state_free(state);
    PBD::remove_directory(new_dir);
    --_state_version;
}
-----------

Then I ran ardour on an old project and ctrl-s'en right away producing the following console output:

State changed (nil)
actually writing state to /home/deva/sigkill/sigkill-001/sigkill-001.tmp
renaming state to /home/deva/sigkill/sigkill-001/sigkill-001.ardour

clicking ctrl-s again rendered this output:

State didn't change.
actually writing state to /home/deva/sigkill/sigkill-001/sigkill-001.tmp
renaming state to /home/deva/sigkill/sigkill-001/sigkill-001.ardour


+++

It seems that the initial value of _impl->state is null after initial project load always forcing a store on first project save, regardles of changes in the plugin state.
TagsNo tags attached.

Activities

deva

2015-09-26 10:46

reporter   ~0017355

Last edited: 2015-09-26 11:09

I would like to add that the reason why this is an issue for me, is that I am using git to store my session, and this bug makes it impossible for me to track the plugin state since I have to add new state folder/file, each time I work on the session even though I didn't make changes to the plugin config.

2015-09-26 14:35

 

lv2_state.patch (430 bytes)   
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index cd1c190..5db3b16 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -1696,6 +1696,7 @@ LV2Plugin::set_state(const XMLNode& node, int version)
 			_world.world, _uri_map.urid_map(), NULL, state_file.c_str());
 
 		lilv_state_restore(state, _impl->instance, NULL, NULL, 0, NULL);
+		_impl->state = state;
 	}
 
 	latency_compute_run();
lv2_state.patch (430 bytes)   

deva

2015-09-26 14:37

reporter   ~0017358

I added a patch that seem to fix the issue but it'll need the eyes of someone more into the whole lilv integration thing to see if it is actually the right way to do it.

On a slightly different note; I found a potential memory leak for which I have added another patch.

2015-09-26 14:38

 

lv2_state_leak_fix.patch (406 bytes)   
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index cd1c190..c6a6e31 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -480,6 +480,7 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate)
 	if (state && _has_state_interface) {
 		lilv_state_restore(state, _impl->instance, NULL, NULL, 0, NULL);
 	}
+	lilv_state_free(state);
 #endif
 
 	_sample_rate = rate;
lv2_state_leak_fix.patch (406 bytes)   

deva

2015-09-26 14:59

reporter   ~0017359

After testing the patch it appears that the state is not longer changed, but a new state dir is created and not correctly removed.
Example, it keeps state1 in the session, but creates an empty state2 dir.

x42

2015-09-27 12:08

administrator   ~0017372

Patches applied in Ardour 4.2-424-ged2ce36

Thanks for this.

deva

2015-09-27 12:13

reporter   ~0017373

confirmed.

system

2020-04-19 20:17

developer   ~0023534

Issue has been closed automatically, by Trigger Close Plugin.
Feel free to re-open with additional information if you think the issue is not resolved.

Issue History

Date Modified Username Field Change
2015-09-26 09:55 deva New Issue
2015-09-26 10:46 deva Note Added: 0017355
2015-09-26 11:09 deva Note Edited: 0017355
2015-09-26 14:35 deva File Added: lv2_state.patch
2015-09-26 14:37 deva Note Added: 0017358
2015-09-26 14:38 deva File Added: lv2_state_leak_fix.patch
2015-09-26 14:59 deva Note Added: 0017359
2015-09-27 12:08 x42 Note Added: 0017372
2015-09-27 12:08 x42 Status new => resolved
2015-09-27 12:08 x42 Resolution open => fixed
2015-09-27 12:08 x42 Assigned To => x42
2015-09-27 12:13 deva Note Added: 0017373
2020-04-19 20:17 system Note Added: 0023534
2020-04-19 20:17 system Status resolved => closed