Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 2600 - Compact project followed by undo restores the last saved state
Compact project followed by undo restores the last saved state
Status: CLOSED FEATURE DISABLED
Product: Audacity
Classification: Unclassified
Component: Application Core
3.0.0
All All
: P1 RepeatableAll
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-11-25 08:07 UTC by Peter Sampson
Modified: 2020-11-30 05:48 UTC (History)
7 users (show)

See Also:
Steps To Reproduce:
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 Echo" 8) Select that 9) Observe track is deleted (project reverts to that saved at Step 1)
Release Note:
Group: Compaction Compact project followed by Undo restores the last saved state of the project not the state at compaction.
First Git SHA:
Group: ---
Workaround:
Use Redo to restore the project
Closed: 2020-11-30 00:00:00
james.k.crook: Must‑Test‑All‑OS+
petersampsonaudacity: Quickfix‑Requested+
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+


Attachments
Leland's post compaction History stack and undo grayed-out (52.31 KB, image/png)
2020-11-25 09:07 UTC, Peter Sampson
Details
Testing after fix 1efebb7 (72.44 KB, image/png)
2020-11-26 09:30 UTC, Peter Sampson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Sampson 2020-11-25 08:07:46 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
Comment 1 Peter Sampson 2020-11-25 08:12:11 UTC
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
Comment 2 Peter Sampson 2020-11-25 08:15:56 UTC
This was discovered while testing Bug #2590
Comment 3 Peter Sampson 2020-11-25 09:07:23 UTC
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.
Comment 4 Paul L 2020-11-25 11:03:23 UTC
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.
Comment 5 Peter Sampson 2020-11-25 11:14:24 UTC
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).
Comment 6 Paul L 2020-11-25 13:36:50 UTC
Fixed at ebb6e5de1c814fffabeec867a57c15c103488217 by simple renaming of the current undo state after compacting
Comment 7 Paul L 2020-11-25 13:45:13 UTC
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
Comment 8 Peter Sampson 2020-11-26 09:30:13 UTC
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
Comment 9 Peter Sampson 2020-11-26 09:31:31 UTC
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
Comment 10 Steve Daulton 2020-11-26 15:16:22 UTC
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.
Comment 11 Peter Sampson 2020-11-27 09:12:55 UTC
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
Comment 12 James Crook 2020-11-27 10:20:39 UTC
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.
Comment 13 Peter Sampson 2020-11-28 06:48:59 UTC
(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.