Skip to content

Commit

Permalink
PR #9299 from Nir: remove playback dtor flush() to fix rare crash
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Jun 28, 2021
2 parents 79efea8 + 3a72cb8 commit 83ce524
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
17 changes: 3 additions & 14 deletions src/media/playback/playback_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ rs2_extrinsics playback_device::calc_extrinsic(const rs2_extrinsics& from, const

playback_device::~playback_device()
{
(*m_read_thread)->invoke([this](dispatcher::cancellable_timer c)
{
std::lock_guard<std::mutex> locker(_active_sensors_mutex);
for (auto&& sensor : m_active_sensors)
Expand All @@ -161,12 +160,6 @@ playback_device::~playback_device()
sensor.second->stop();
}
}
});

if((*m_read_thread)->flush() == false)
{
LOG_ERROR("Error - timeout waiting for flush, possible deadlock detected");
assert(0); //Detect this immediately in debug
}

(*m_read_thread)->stop();
Expand Down Expand Up @@ -454,8 +447,8 @@ void playback_device::start()
catch_up();
try_looping();
LOG_INFO("Playback started");

}

void playback_device::stop()
{
LOG_DEBUG("playback stop called");
Expand All @@ -469,8 +462,8 @@ void playback_device::stop()
LOG_ERROR("Error - timeout waiting for flush, possible deadlock detected");
assert(0); //Detect this immediately in debug
}
LOG_INFO("Playback stoped");

LOG_INFO("Playback stopped");
}

void playback_device::stop_internal()
Expand All @@ -482,10 +475,7 @@ void playback_device::stop_internal()

m_is_started = false;
m_is_paused = false;
for (auto sensor : m_sensors)
{
//sensor.second->flush_pending_frames();
}

m_reader->reset();
m_prev_timestamp = std::chrono::nanoseconds(0);
catch_up();
Expand Down Expand Up @@ -524,7 +514,6 @@ void playback_device::do_loop(T action)
{
if( psc )
{
psc->flush_pending_frames();
psc->stop( false );
}
}
Expand Down
20 changes: 8 additions & 12 deletions unit-tests/live/rec-play/test-got-playback-frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,14 @@ def stop_sensor( sensor ):
except Exception:
test.unexpected_exception()
finally: # we must remove all references to the file so we can use it again in the next test
if recorder:
recorder.pause()
recorder = None
if playback:
playback.pause()
playback = None
stop_sensor( depth_sensor )
depth_sensor = None
stop_sensor( color_sensor )
color_sensor = None
if recorder:
recorder = None
if playback:
playback = None

test.finish()

Expand Down Expand Up @@ -240,16 +238,14 @@ def stop_sensor( sensor ):
except Exception:
test.unexpected_exception()
finally: # we must remove all references to the file so the temporary folder can be deleted
if recorder:
recorder.pause()
recorder = None
if playback:
playback.pause()
playback = None
stop_sensor( depth_sensor )
depth_sensor = None
stop_sensor( color_sensor )
color_sensor = None
if recorder:
recorder = None
if playback:
playback = None

test.finish()

Expand Down
4 changes: 4 additions & 0 deletions unit-tests/py/rspy/libci.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ def command( self ):
# -S : don't imply 'import site' on initialization
# NOTE: exit() is defined in site.py and works only if the site module is imported!
cmd += ['-S']
# -u : force the stdout and stderr streams to be unbuffered; same as PYTHONUNBUFFERED=1
# With buffering we may end up losing output in case of crashes! (in Python 3.7 the text layer of the
# streams is unbuffered, but we assume 3.6)
cmd += ['-u']
if sys.flags.verbose:
cmd += ["-v"]
cmd += [self.path_to_script]
Expand Down

0 comments on commit 83ce524

Please sign in to comment.