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

Audacity Bugzilla



Bug 437 - Write fails without error message box on disk full
Write fails without error message box on disk full
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Application Core
1.3.14 alpha
Per OS All
: P2 Repeatable
Assigned To: Paul L
: patch_closed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-29 17:31 UTC by Gale Andrews
Modified: 2020-09-22 05:16 UTC (History)
9 users (show)

See Also:
Steps To Reproduce:
1 Fill a smaller or external/zip/flash drive to about 85% capacity. 2 Launch Audacity, generate enough Noise almost fill the drive (10 MB space per minute required for mono 32-bit). 3 Save Project 4 Generate enough tone to very slightly overfill the drive 5 Open Help > Show Log. Write errors are noted "09:23:00: Error: Write error on file 'I:\2min_data\e00\d00\e00001bf.au'(error 112: there is not enough space on the disk.)" But no error message is shown to user. 6 Inspect the waveform. Looks OK until you zoom in to the end where you can see silence.
Release Note:
GROUP:Projects * '''There are currently no message box warnings when projects run out of disk space.''' If you run out of disk space when editing or recording, patches of silent or corrupted audio will appear, which will also be present if you save and reopen the project. Be aware that every effect applied to a complete track takes as much in disk space as if you were recording that entire track, and partial changes take proportional amounts of space, due to the ability to undo and redo. You can go to View > History and discard Undo levels to free up space.
First Git SHA:
Group: ---
Workaround:
Closed: 2018-08-20 00:00:00
gale: Regression+
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+
stevethefiddle: Test‑OK‑Lin+


Attachments
Patch from Ed to correct the most likely silent write failures on disk full (21.90 KB, patch)
2011-07-29 17:35 UTC, Gale Andrews
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gale Andrews 2011-07-29 17:31:18 UTC
If editing the existent data, errors like: 
09:34:11: Error: Expected to read 14517 samples, got 0 samples.

will appear in the log but not conveyed to user.

Exiting and re-opening the project produces no errors (legitimately as it stands, because there are no orphans or missing files) but of course it has the same unintended silences. 

If you save the project to the full drive you will see log messages like:
09:52:17: Error: Failed to copy the file 'I:\2min_data\e00\d00\e000057b.au'
to 'I:\aaa_data\e00\d00\e000057b.au' (error 112: there is not enough space
on the disk.). Again no user warning is presented.  

Observation: 1.2 tends to bombard user with warnings when it runs out of disk space, to the extent you can't do much but force quit. Errors should be aggregated I think, certainly not one message box per log error.
Comment 1 Gale Andrews 2011-07-29 17:35:30 UTC
Created attachment 188 [details]
Patch from Ed to correct the most likely silent write failures on disk full
Comment 2 Ed Musgrove 2011-07-29 19:47:27 UTC
(In reply to comment #2)
Gale said (and it seems to be the trend on -dev) "Errors should be
aggregated I think, certainly not one message box per log error."

I resolved this by trapping the first error, not retrying (seems to be the trend on -dev), popping a dialog telling the user of the specific error, rolling back all successful Write()s in the current operation, doing a complete recovery of memory allocations and cleaning up any leftover orphans (files & folders); then a second dialog appears saying "could not (save or whatever)". Only the single Log entry occurs and there is no cascade.
Comment 3 Vaughan Johnson 2012-01-24 23:20:32 UTC
(In reply to comment #2)

Issues with the patch: 

* AudioIO.cpp: Putting up wxMessageBox from AudioIO will cause thread issues, right? Also, bad form to present method name and tech details to users, except possibly in the log. E.g., "AudioIO::FillBuffers mCaptureTracks[i]->Append failed 1" -- a user can only be nonplussed by that.

* SimpleBlockFile.*: mbHadWriteFailure is used only outside the class. 

* DirManager.cpp: Why remove the default parameter values in the declaration of RecursivelyEnumerate? Note that in DirManager::CleanTempDir, RecursivelyEnumerate is called without specifying those values. Does that even compile for you? You did the same thing on other methods. And there are lots of changes that look like they're just spaces added or removed. In general, why make any change if it "ain't broken"? Just makes more code to review, unnecessarily.

* DirManager.cpp: Similar comment about text in messages to user: "file write error DEBUG" isn't even a sentence.

* DirManager.cpp: Weird to throw an XMLFileWriterException in a non-XMLFileWriter class. Plus, your messages cite wxWidgets methods -- again, totally perplexing to a user.

* It looks like you did not address the commented TODO places "out of disk space". 


That's enough problems in specifics, as much as I'm willing to review at this point.


I think this patch needs a *lot* of work. Also, it adds a lot more text to user, and that would require a lot of translation work. Overall, I don't think it's worthwhile before 2.0. 


Your patch makes *lots* of changes unrelated to this bug, and lots of similar code in many places. I suggest that we address only the topic of this bug, because it's fairly significant. 

And I think there must be a better locus of where to discover and back out of its occurrence. We should at least start with the "out of disk space" situations already noted in the code. And check all the wxASSERT calls in Sequence. 


Also, rather than putting removal code in lots of places, did you look into just doing an internal Undo upon failure?


Finally, fwiw, the "Error" entries in the log are generated by wxWidgets, not our code. I'll look into debugging at least where this happens per the Steps. 


Thanks for the effort!
Comment 4 Vaughan Johnson 2012-02-01 19:34:41 UTC
(In reply to comment #3)

In commit r11447, I modified WriteSimpleBlockFile to check the results of all its calls to wxFFile::Write(), and return false if any fails. They're now noticed with a wxASSERT() in SimpleBlockFile constructor. Unfortunately, the current architecture does not make it easy to alert user to this via dialog, but at least we now check for it and catch it in debug.

Ed, if you have comments on my questions in comment #2, I'm open to them. In particular, the 'throw' to get around the architecture issues, might have merit. Other than that, I think further work on this should wait until post-2.0.
Comment 5 James Crook 2015-04-27 15:17:18 UTC
Patch rejected, per comments by Vaughan.
Comment 6 James Crook 2015-09-24 10:48:51 UTC
Raised to P2, because it appears as a listed limitation on the Wikipedia Audacity page, so is having a significant impact on the perception of Audacity.

Wording of release note changed as edits (cut and paste) need not take much space, but an effect applied to the whole track does.
Comment 7 Peter Sampson 2015-10-06 09:26:40 UTC
We do actually provide an estimate of recording time left available (based on free disk space) in the Status Bar message - but I'm guessing that many folk don't notice that or pay much attention to it.

Maybe in addition we could, on Audacity start-up, flash up a message dialog in "large friendly letters" also showing how much recording time is available (and maybe making a reference there to the Status Bar space/time monitor).
Comment 8 James Crook 2015-10-06 09:53:28 UTC
(In reply to Peter Sampson from comment #7)
But we don't tell users when they have actually run out, and that is the problem.
Comment 9 Peter Sampson 2015-10-11 09:44:11 UTC
(In reply to James Crook from comment #8)
Indeed, but telling them when they have "actually run out" is probably a bit too late.

Ideally we should warn them as disk space is getting critically low (10%, 5%? - less?), telling them how much recording time remains, so they can halt the recording if appropriate/possible.  

If they choose not to stop recording then Audacity should periodically remind them with the same warning message with the new space/time remaining.

If they are about to totally run out of space Audacity should stop recording of its own accord and tell the user why it did so.  We should not wait until all available space has gone as not all OSs cope well with a disk full situation.

The same space/time warning message is the one I would like to see shown on startup (with an option, a preference, to be able to turn off the startup message).

The running out of space messages should be mandatory imo and should not be capable of being turned off.
Comment 10 Peter Sampson 2015-10-11 09:45:50 UTC
The more I look at this the more I think that this bug really deserves P1 status.
Comment 11 Gale Andrews 2015-10-12 04:46:37 UTC
(In reply to Peter Sampson from comment #9)
There is a message of low temporary space on launching Audacity (100 MB, IIRC). But you can then save an empty project to another drive with almost no space and get no warning there is little space there.  

There is an out of disk space warning in the status bar when you run out during recording.    

Just the same as stopping recording when out of space, Audacity should not go ahead with an edit that it can see in advance it does not have the space for, which will result in damage to the audio (not immediately apparent when zoomed out). 

I think P2 will have to do for now.
Comment 13 James Crook 2017-03-02 10:43:24 UTC
We now have 36 FIXME: TRAP_ERR comments in the Audacity source code.  If these are fixed then probably we have caught all can't write to disk issues.  We need to write the code once to report the error and abort recording or abort whatever other disk-writing activity is in progress.  Using RAII idiom is important for many of these.
Comment 14 Paul L 2017-04-03 23:48:05 UTC
This bug report set me off on a very large project to handle disk failures, identifying not only recording but other places where some possibility (though not as great a probability) of disk space exhaustion exists, and checking that incomplete side effects get properly rolled back between detection of errors and reports to the user.

I also considered where exceptions should be thrown for failures to read.  Perhaps to test these fixes you could do lengthy operations on projects stored on external devices, and disconnect cables before they finish.  For drawing or playback, just substitute silence, but abort other operations with a user visible message.

The project is complete here:

https://github.com/audacity/audacity/commit/d417acd5c66f642db6efb205c8c640cfb7b106f9
Comment 15 Paul L 2017-07-23 21:53:06 UTC
Belatedly, I call fix made.  I think I have done enough to address what's in the bug title and in the steps to reproduce.

That is, no more silent failures resulting in projects in a corrupt state.  (Whether from recording sound, or generating it, or applying an effect that increases the size needed for undo history beyond capacity.)

I count only 25 TRAP_ERR comments left.  I will not remove more of them now.

The ideas linked in comment 12, for estimating and anticipating disk exhaustions before they happen, is not in the scope of my work.  If that is a good idea, make it an enhancement request.
Comment 16 Peter Sampson 2017-07-27 12:07:58 UTC
(In reply to Paul L from comment #15)
Testing on W10 audacity-win-rf1aa916-2.2.0-alpha-23-jul-17
and on macOS Sierra 10.12.5 00f8658 27Jul17

Testing with a USB clip drive with limited space
1) Recording
2) Effects like Amplift
3) Dulicates/align/Mix&Render
4) Export as WAV

all failed cleanly with the error message appearing, clearly identifying the problem drive.

I'm not sure why this was ever marked as a regression because AFAIK Audacity has never in previous releases trapped this error - and nor has it failed cleanly.

A big round of applause to Paul for finally fixing this   :-))


I don't think we need to raise a bug for tracking the earler trapping of such events - the proposal linked to in Comment #12 should suffice - see:
http://wiki.audacityteam.org/wiki/Proposal:_Earlier_Disk_Over-run_Warnings
Comment 17 Paul L 2017-07-27 12:19:33 UTC
I emphasize again that the hard part is making sure that after the message is raised in the middle of a failed operation, the project and the disk reverts completely to its status quo ante (except, in case of recording, keeping as much new recording as possible), and that "nothing funny happens" with continued use of Audacity thereafter.  

Making this guarantee was the hard programming work requiring review of hundreds of things in the code.

Proving the negative, "nothing funny," is impossible, but I take it you are satisfied there was no grossly obvious slapstick going on.
Comment 18 Peter Sampson 2017-07-27 12:25:12 UTC
(In reply to Paul L from comment #17)
>Proving the negative, "nothing funny," is impossible, 
>but I take it you are satisfied there was no grossly 
>obvious slapstick going on

You take it correctly - the recordings failed with the partial projects left intact.

The only "problem child" was the Export (a WAV export) - and theat left an alleged WAV file behind - but it was not playable - easy for the user to clean up though.


So yes I am "satisfied" - and extremely pleased that once we get 2.2.0 out the door we can remove that "drawback" that has long ben a black mark against us on the Wikipedia Audacity page.
Comment 19 Peter Sampson 2017-07-27 12:26:22 UTC
I also just tested Importing a file larger than could be accomadated on the USB clip drive - also failed cleanly.  No import made, no residue visible.
Comment 20 Paul L 2017-07-27 12:37:34 UTC
Please open bugs, P3 or P4, if you observe that export fails to remove incomplete results.

There are various exporting command (multiple by tracks or by labels, etc.) and some might have a bug and others not.
Comment 21 Peter Sampson 2017-07-27 12:52:22 UTC
(In reply to Paul L from comment #20)
Actually I realized I was testing a fringe case where was almost no soace at all - when I freed up a little more space it produce a nice partila WAV file that was playable - a good clean, graceful, fail/error.
Comment 22 Steve Daulton 2017-07-31 15:54:05 UTC
Testing for the main case as described looks good.
Fringe cases look at least "acceptable" to me.
Anything else could be logged as "enhancements".
Comment 23 Steve Daulton 2017-07-31 15:55:06 UTC
Now tested on all platforms, so closing as fixed.