Bugzilla – Bug 2600
Compact project followed by undo restores the last saved state
Last modified: 2020-11-30 05:48:34 UTC
If you use Undo immediately following the use of File > Compact Project then all the tracks in your project will be deleted. Undo will restore them. Note that, after the Compaction, the History is cleared of all but >created new project >last effect used
Failed on both W10 and macOS 11.0.1 Big Sur - so assume all platforms This is a marginal P2 I'm thinking. Fundamentally Undo should NOT be available after Compaction as Compact Project cannot be undone
This was discovered while testing Bug #2590
Created attachment 1025 [details] Leland's post compaction History stack and undo grayed-out Here is an example (see attachment) of what Audacity was like post compaction in Audacity 3.0.0 d49a888 or earlier. Note that only compaction is on the History stack And note that Undo is properly grayed-out as you cannot undo compaction And importantly Undo was not available => so the tracks could not get deleted as they do now.
I disagree that this is a bug. A more correct title is "Compact project followed by undo restores the last saved state" which happens to be an empty state in this example but would not always be so. As has been explained a few times, we must keep two undo states, the current and the last saved, if they are not the same state. If the possibility of closing without saving, reverting to the saved state, should remain after compacting -- then why not also allow that the easier way, by undoing? Also note that the last saved state might be reached from the current by redo, not undo, if you make edits, save, undo one or more times, and then compact.
OK so I've changed the bug title - and the Release Note and workaround. But what happens will potentially be very confusing to the users, not least because View>History show the last edit performed as does Edit > Undo ... and invoking either of those does *not* undo the last edit as indicated in the command or in the History stack. It would be much better if Undo was grayed-out and unavailable after Compaction , just as Leland had in his original implementation (especially since one can't undo compaction).
Fixed at ebb6e5de1c814fffabeec867a57c15c103488217 by simple renaming of the current undo state after compacting
Sorry I spoke too soon. Previous fix was good enough for the Undo history dialog but didn't correct the menu item text. The COMPLETE fix is at: 1efebb7cdcb3fd4939a564e3775eeb2ed054ab54
Created attachment 1027 [details] Testing after fix 1efebb7 Testing on W10 with Audacity 3.0.0 f5fd860 with some slightly revised steps: 1) Launch Audacity 2) View > History 3) Generate 30 second mono chirp 4) Save project 5) Effect > Wahwah 6) Effect > Echo 7) Observe History stack correctly shows steps 3, 5 & 6 8) File > Compact Project 9) Observe History stack incorrectly shows Chirp and Echo 10) Observe we don't get full compaction (double potential size) 11) View > History to refresh 12) Observe now shows >Applied effect: Chirp (i.e. the last saved state) >Compacted project file 11) Edit menu 12) Observe "Undo Compact" - this is erroneous - you can't undo Compoact) 13) Select that "Undo Compact" 14) Observe project reverts to that saved at Step 4 So: a) Use of Undo after Compact Project still reverts the project to that last Saved state - this is fundamentally wrong and will be confusing to users. The main point of this bug is *not* fixed. b) If you leave the History Window open while working the revised steps, you will observe that the last used command (Echo in this use case) shows as the last (second) item on the history stack with the last saved state as the first item on the history stack (see attachment) - this is erroneous c) If instead you only View>History after the Compaction -or refresh it after compaction with View>History then the second item on the history stack is >Compacted project file this corrects the error from b) d) Observe from the History dialog that we have reverted to compaction (on Windows at least) not providing as much compaction as possible, using twice the file space that it needs to. This was not the case on W10 or Mac when I tested on earlier builds yesterday. e) Using the Edit menu at Steps 11-13 shows "Undo Compact" as an available command. This, in itself, is erroneous as you cannot Undo Compaction - and thus it should be grayed out and unavailable (as Leland previously had it). But worse, if you do use it you don't undo the compaction (as the GUI leads you to believe) rather you revert to that last saved state
I REOPENED this as the bug is still failing what is expressed in the bug title > Compact project followed by undo restores the last saved state
Testing on Linux with f5fd86 Release build. I agree with Peter that this "looks" weird. With f5fd86 the behaviour has changed from "Steps to Reproduce" (step 7) 1) Save empty project 2) Generate 30 minute mono chirp 3) Effect > Wahwah 4) Effect > Echo 5) File > Compact Project 6) Edit menu 7) Observe "Undo Compact" *** THIS STEP CHANGED *** 8) Select that 9) Observe track is deleted (project reverts to that saved at Step 1) I don't think the current behaviour is quite right because: i) After step 5, open the "View > History" window. ii) At step 7, observe that the History window shows "Applied effect: Echo" but the Edit menu says "Undo Compact". Q. When was it decided that "Compact" would delete the Undo history and then compact the database, rather than just compacting the database? I think this needs to be discussed on QA before proceeding with this bug fix.
The problem is compounded as the symptoms of 2600 do not just occur if you effect the Undo immediately after compaction (as in the steps to reproduce). If you make other edits after the compaction and then reverse those with undos and include the Compaction undo you still get reverted to the last saved state. Since this potentially involves hidden un-notified reversion to last =-saved project state and thus a potential loss of data to the user. I doubt that most of them would not even notice at first. The steps I used in Comment #8 were deliberately chosen so that I could see the visual difference at each step in the use case - so I could clearly see that the Undo step reverted the waveform to the simple unedited chirp. Now consider the real use case of a user with a song or their audiobook recording,here we have: a) a complex waveform and making edits and applying edits is not always readily visible, b) and thus the user may be blissfully unaware of the state they have been returned to with the Undo. Because of this risk of "hidden" data loss I am going to raise this to P1
DEVEL - FIX MADE https://github.com/audacity/audacity/commit/ad857551016947306e9d65e648bef0b1b8935727 As this is a P1 bug, the fix must be tested on all 3 platforms.
(In reply to James Crook from comment #12) Tested on W10 and macOS 11.0.1 with Audacity 3.0.0 ad85755 This bug no longer exists on Win or Mac as the Compact Project command has been withdrawn for UP-3.0.0. I have updated the Manual and provided a workaround.