Thanks Paul.
independent analysis/fix.
for out of memory in one place 'at the top' of the GUI. Given your
don't currently have time to do that.
There are two parts to terminating record. One is actually stopping
recording. The other is updating the GUI to show it has stopped.
Stopping the actual recording should happen in the recording thread.
Updating the GUI should happen in the GUI thread. Currently in your 437
like to stop. The net result is that actual recording stops 'later'
than it should when we run out of disk space. We probably get away with
recording. That delay isn't inherent in the problem.
As RM I am looking at the risks of fixing 437 anew. The changes are
fix is also likely to be substantially longer than I anticipated.
Releasing is a feature. I'm therefore going to not block on 437 any
more. We'll have another go at it for 2.1.4. So current plan is to go
into freeze tomorrow. We'll be just over a week in freeze, and then
working to release.
--James.
Post by Paul LicameliAttn James
Post by James CrookPost by Paul LicameliPost by James CrookAm a little (but only a little) concerned that we effectively have
::wxMessageBox( e.ErrorMessage() );
in three places. We could end up modifying all three places with later
improvements to reporting. It could be argued that if we are using
exceptions at all for this we should do so 'consistently' and handle and
rethrow as necessary. I'm OK with the current approach though for
2.1.3.
Post by Paul LicameliWhat do you mean? The three places mentioned stop the propagation of
error
Post by Paul Licameliwith a recovery. (Actually one of them is not a catch, because of the
problem of communicating the exception inter-thread.)
The concern is it's not DRY.
https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
It's true ::wxMessageBox is only a one liner, and if we later make it a
custom error dialog we will just call the function for that instead.
Nevertheless a part of me is concerned that 'that code to report an
exception to the user' is in three places.
I'm not really repeating myself. I want as few catches as possible but not
fewer. However, that number will be more than three, and they really need
to to different things.
To repeat, the recording problem is inherently different from the others,
because inter-thread communication is needed, and the recovery we want to
do (saving partial results rather than rolling back) is different. It
really needs special code.
I avoided some repetition I might otherwise have had: It took a little bit
of research to figure out that AudacityApp::OnExceptionInMainLoop was a
single high-enough level place to catch errors from dispatch of
CommandManager functors, but also things like track control panel menu
items and presses of Edit toolbar buttons, that don't go through the
command manager. Otherwise I would have written more catch blocks. This
single high level catch is a good thing.
The catch block in BenchmarkDialog::OnRun is just for completeness,
catching a very low probability case that can only affect alpha users who
invoke Audacity from the command line.
But now I think I need more catches, which will do yet other recovery
actions. That is because the exception can happen within callback
functions we write that are called from C libraries such as Nyquist and
various import libraries. I fear such C code is not equipped to handle C++
error propagation through the stack, and the state of the libraries could
be corrupted. The various callback protocols do allow the function to
return an error code instead. So I must add a catch in each callback and
return an appropriate code which varies with the library.
Much code we write are in fact event-handling callbacks too, for wxWidgets,
but I will assume that library is written to tolerate exception propagation
through its stacks. After all they invite you to override
wxApp::OnExceptionInMainLoop.
But now I also fear that this guarantee might not apply to overrides of
wxAccessible methods, which get invoked via other paths (on Windows, in a
method of a COM object; on Mac, with my wxWidgets patches, within layers of
Objective-C). So, I may write more catches.
Or maybe it is enough that in AButton::Click, we call not ProcessEvent but
SafelyProcessEvent so that AudacityApp::OnExceptionInMainLoop has the
opportunity to intercept exceptions for exhaustion of disk space. But now
this makes me wonder whether every one of our uses of ProcessEvent may
likewise need to be replaced with SafelyProcessEvent. Maybe not, because
the topmost event handling loop of the application is still the catch-all
in other cases and there are only layers of our code and wxWidgets code in
between.
CommandManagerEventMonitor::FilterEvent makes an objective-C closure and
that may need to stop exception propagation too.
Post by James CrookPost by Paul LicameliDo you worry about all the intermediate levels of stack that get unwound
needing to catch and rethrow? Well no, not if they use RAII properly,
but
Post by Paul Licamelithen there are many such places and that is what I am doubtful of.
It's more an instinct that the ::wxMessageBox should (maybe) be a catch
right at the top.
I think the 'correct' design is that the original exception actually
stops recording NOT the TrackPanel Timer event. The TrackPanel Timer
Event should only be concerned with GUI things, such as making sure the
record button pops up ... and signalling upwards that an error
reporting dialog for the user is needed.
You're signalling the BadWriteException for recording 'upwards' by
testing state, but elsewhere in the GUI code are using an exception to
signal an error in operations upwards. That's why I am talking about
rethrowing - as a way to merge the two approaches. I get that in the
other cases you undo the partial operation, and that that is not right
for the record case. Maybe a flag is needed in the exception that can
be cleared before rethrowing to control that?
It's not that I worry that the code you've written won't work. Rather it
is about separation of concerns - Recording thread stops the recording;
Repainting Timer ensures visuals are right e.g. button pop ups; Top
level catch ensures error is reported to user. Of course we do currently
put more in our GUI thread than we should so it's not as if it's a new
problem.
The asynchronicity is really an inherent difficulty here. The timer in
TrackPanel already polls for the end of playback happening asynchronously
in the other threads, so that it could change button states. Now that
recording might asynchronously stop too, because of disk exhaustion
detected in the worker thread, this seemed a good place to keep all such
polling together.
Post by James CrookPost by Paul LicameliAre these three catches complete? I do not yet know. I have not
finished
Post by Paul Licamelithe examination of the code. I have to discover a very large ascending
call graph from NewSimpleBlockFile. I have been writing that in a text
file and it gets pretty big.
I see the need for that exercise. For example I can imagine that the
summary files are a potential additional problem, as if you've failed to
write a block then you shouldn't write the summary file either.
The excercise is still not complete.
This thing is really ballooning -- not the fixes, but the effort to be sure
they are complete. Should I still bother?
It will be good to eliminate a rather low numbered high priority bug, and
it also happens that every occurrency of the comment
// TO DO: Actually handle this.
is in one of the functions that I discovered in the graph. Though perhaps
the comment is not added in every place it ought to be. Yet it means there
is a neglected check of an error code. Perhaps with a little more effort
all such functions could return void and instead throw other subtypes of a
new base class that they will share with BadWriteException. Then, strike
many TO DOs as done.
PRL
Post by James Crook--James.
------------------------------------------------------------
------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel
------------------------------------------------------------------------------
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel