# Buggy code
def scan_path_gaze_for_frame(self, frame):
    if self.timeframe == 0.0:
        return None

    if not self._gaze_data_store.is_valid or not self._gaze_data_store.is_complete:
        if not self.is_active:
            self._trigger_immediate_scan_path_calculation()
        return None

    timestamp_cutoff = frame.timestamp - self.timeframe

    gaze_data = self._gaze_data_store.gaze_data
    gaze_data = gaze_data[gaze_data.frame_index == frame.index]
    gaze_data = gaze_data[gaze_data.timestamp > timestamp_cutoff]

    return gaze_data


# Traceback (AttributeError)
2020-03-26 19:12:22,171 - Export World Video - [DEBUG] scan_path.controller: ScanPathController._on_preproc_started
2020-03-26 19:12:22,172 - Export World Video - [INFO] background_helper: Traceback (most recent call last):
File "shared_modules/observable.py", line 256, in call_all_observers
File "shared_modules/observable.py", line 304, in __call__
File "shared_modules/vis_polyline.py", line 153, in _update_scan_path_ui
AttributeError: 'Vis_Polyline' object has no attribute 'menu_icon'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "shared_modules/background_helper.py", line 73, in _wrapper
File "shared_modules/video_export/plugins/world_video_exporter.py", line 275, in _export_world_video
File "shared_modules/vis_polyline.py", line 146, in recent_events
File "shared_modules/vis_polyline.py", line 180, in _draw_polyline_path
File "shared_modules/scan_path/controller.py", line 109, in scan_path_gaze_for_frame
File "shared_modules/scan_path/controller.py", line 140, in _trigger_immediate_scan_path_calculation
File "shared_modules/scan_path/tasks/preprocessing.py", line 76, in start
File "shared_modules/observable.py", line 251, in __call__
File "shared_modules/observable.py", line 265, in call_all_observers
File "shared_modules/observable.py", line 256, in call_all_observers
File "shared_modules/observable.py", line 304, in __call__
File "shared_modules/scan_path/controller.py", line 147, in _on_preproc_started
File "shared_modules/observable.py", line 251, in __call__
File "shared_modules/observable.py", line 267, in call_all_observers
observable.ObserverError: An observer raised an exception.

2020-03-26 19:12:22,172 - Export World Video - [DEBUG] background_helper: Exiting _wrapper
2020-03-26 19:12:22,182 - player - [ERROR] launchables.player: Process Player crashed with trace:
Traceback (most recent call last):
File "launchables/player.py", line 606, in player
File "shared_modules/task_manager.py", line 84, in recent_events
File "shared_modules/task_manager.py", line 88, in _manage_current_tasks
File "shared_modules/task_manager.py", line 112, in _update_running_tasks
File "shared_modules/task_manager.py", line 258, in most_recent_result_or_none
File "shared_modules/background_helper.py", line 115, in fetch
observable.ObserverError: An observer raised an exception.

2020-03-26 19:12:22,182 - player - [INFO] launchables.player: Process shutting down.

# Fixed code
def scan_path_gaze_for_frame(self, frame):
    if self.timeframe == 0.0:
        return None

    if not self._gaze_data_store.is_valid or not self._gaze_data_store.is_complete:
        if not self.is_active and self.g_pool.app == "player":
            self._trigger_immediate_scan_path_calculation()
        return None

    timestamp_cutoff = frame.timestamp - self.timeframe

    gaze_data = self._gaze_data_store.gaze_data
    gaze_data = gaze_data[gaze_data.frame_index == frame.index]
    gaze_data = gaze_data[gaze_data.timestamp > timestamp_cutoff]

    return gaze_data