-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discard history on project-file save/load #2400
Discard history on project-file save/load #2400
Conversation
Believe it or not, in all the logging OpenShot does, never was the fact that a project file was being loaded or saved actually logged as such. Now it is, complete with the `file_path`.
On both load and save of project file data, any `"history"` in the JSON will be discarded, replaced with an empty struct: `{ "undo": [], "redo": [] }` Temporarily, while testing the feature, the total size of the data structure being discarded will first be computed and logged. ``` project_data:INFO Discarding history of size 105246892 bytes ```
P.S> 56fa87a adds logging at the start of project-file save and load operations — previously it only logged at the completion of those operations, which is no help from a debugging standpoint. You want to know if anything untoward happens during the save/load operation. |
@ferdnyc - I'm supposed to be on a break from this project but I'm very interested and excited to test this change. This is the best PR ever for the project in recent times and could solve a whole lot of bad experiences related to performance issues across the board. |
@ferdnyc - I had a brief test of this and it didn't appear to be saving any undo history during my session. I tested both an old project and created a new one. Should I have deleted the Openshot preferences folder before testing this? |
Meaning, undo didn't work within your session? Oh, it's not supposed to break that! I thought I'd tested that from every angle but I may have missed something.
No, there are no preferences changes or changes to the default project, only save/load of project file data are supposed to be affected. But maybe I missed something in how new-project setup is handled. I'll test through project creation, especially, more thoroughly and carefully when I can... later tonight or tomorrow, hopefully. |
@ferdnyc - Nevermind. I think I was a bit confused on what I was looking for here. I had the project file open in an editor and for some reason expected the undo json to be populated with data. Undo and Redo did work in my session. 😆 |
Yeah, that's specifically what this PR does away with, because of all the problems (performance, path issues, outright crashing) it's caused to be storing history. I still feel it's a nice feature to provide history persistence across sessions. But only if it can be done safely, reusably, and without destroying OpenShot's performance, which the current implementation falls short of. |
openshot-qt/src/classes/updates.py Lines 72 to 84 in e8633bf
My suspicion, BTW, is that the bug that blows out the history lives right here in the code. You can see where it tests I think the test should be something different, at least for the non if "history" in data_dict["key"]:
do_something() # though I'm honestly not sure what
# or
if "history" in data_dict["value"]:
data_dict["value"].pop("history") (I know that updates with |
I should also note that I'd prefer to have @jonoomph OK this change before it merges, since history persistence across sessions has been explicitly held up as a desirable feature (see e.g. 86f1d48) and it doesn't feel like it should be my call to do away with that, whatever problems it's causing. (The recursive history entries is only one of those problems — the other major one being outright crashes, caused by expired AppImage transition paths in the history — but the recursion was thought fixed in #2084, the change that introduced the code I highlighted in the previous comment.) |
Since
I'd be happy to take responsibility for the merge, if you two are not against it. |
|
@jonoomph - Can you review this change? |
@ferdnyc - We have been notified about this. The plan is to clean up the newer commits to make them translate-able, I guess. Once that is done, plans are to go through each of the PRs. That is why the optimism. Hopefully, this (and other PRs) will be merged really soon. |
This PR contains no translatable strings, its only output is to the log. |
Not this PR, sir. The others that have been merged. I guess he's just trying to polish up what is in the main tree already and once that is done (which I hope it is) he'll be in the currently open PRs. Hope that clears up the confusion. |
Heyyo @ferdnyc ! Looking at this now! |
Yeah, originally I thought this would be a great feature, to persist history across sessions. However, as noted above, this has some ugly repercussions... such as bloated file sizes and incorrect paths. One issue I "thought" was resolved (but might not be), is the storing of nested histories. For example, a project has history [], and then someone would save or load a project, which would add the entire project, plus the entire history [] as a nested structure... thus really, really, really ballooning the size. That might still be happening, not sure. |
Merging this into a test branch, so I can see if it passes all the different OS build servers |
Also, I'm not sure if the risk of total_size() method is really needed. I might remove that logging before merging this into develop, FYI... unless there is a really critical reason to keep it. =) |
* Discard history on project-file save/load (#2400) * updates.py: add newline at end of file * conversion: total_size() for data structs * project_data: Log load and save operations Believe it or not, in all the logging OpenShot does, never was the fact that a project file was being loaded or saved actually logged as such. Now it is, complete with the `file_path`. * project_data: Discard history On both load and save of project file data, any `"history"` in the JSON will be discarded, replaced with an empty struct: `{ "undo": [], "redo": [] }` Temporarily, while testing the feature, the total size of the data structure being discarded will first be computed and logged. ``` project_data:INFO Discarding history of size 105246892 bytes ``` * Removing logging of history size, since it does not serve much of a purpose. Soon we need to revisit this and try and improve the persistance of history (within reason to a few dozen changes perhaps), and ensure we don't allow nested histories (since history is an attribute of a project object).
Merged into develop! Thanks @ferdnyc ! |
On both load and save of project file data, any
"history"
in the JSON will be discarded, replaced with an empty struct:Temporarily, while testing the feature, the total size of the data structure being discarded will first be computed and logged. (I added a
total_size()
function, taken from a python recipe — there's a link in the comment header — toclasses/conversion.py
, which maybe isn't the best spot but oh well.)(That's @peanutbutterandcrackers' 12MB mega-exploded project file — turns out, that history turns into One Hundred Five megabytes in memory!)
In my testing, this works seamlessly. History operates normally when using OpenShot, and can be undone and redone as usual. Even after saving a project, the history is still there in that session. However, when you load a project, instead of the Undo history being populated, it's now always cleared, so history only persists through the session.
If you load old project files and resave them, the history will be removed. (Actually, that can happen anyway with autosave — I've accidentally lost the long history in more than a few of my test projects already, in testing this code out. Which is making it harder to actually test! But, in a good way. And I could always turn off autosave.)
Kick the tires, see what you think. Hopefully this gives OpenShot a kick in the ass, performance-wise, especially for people with project files that have ballooned in size. And it should also eliminate any history crashes caused by absolute paths to AppImage mounts.
Fixes #1923
Addresses (possibly) #1768