Skip to content

[Bug]: visualize fails when no screenshots are present #762

Description

@abrichr

Describe the bug

via @alphadev on Discord:

               {'id': 5714,
                'mouse_pressed': False,
                'timestamp': 1718573830.5520644}],
  'mouse_button_name': 'left',
  'mouse_x': 1498,
  'mouse_y': 894,
  'name': 'singleclick',
  'reducer_names': {'mouse_click'},
  'screenshot_timestamp': 1718573840.951178,
  'timestamp': 1718573829.9590232,
  'window_event_timestamp': 1718573830.6910732},
 {'canonical_text': '<shift>-h',
  'children': [{'canonical_key_name': 'shift',
                'id': 5715,
                'key_name': 'shift',
                'name': 'press',
                'screenshot_timestamp': 1718573842.0284984,
                'timestamp': 1718573841.993897},
               {'canonical_key_char': 'h',
                'id': 5716,
                'key_char': 'H',
                'key_vk': '72',
                'name': 'press',
                'screenshot_timestamp': 1718573842.1779761,
                'timestamp': 1718573842.1290543},
               {'canonical_key_name': 'shift',
                'id': 5717,
                'key_name': 'shift',
                'name': 'release',
                'screenshot_timestamp': 1718573842.1779761,
                'timestamp': 1718573842.2468576}],
  'name': 'type',
  'reducer_names': {'keyboard'},
  'screenshot_timestamp': 1718573842.0284984,
  'text': '<shift>-H',
  'timestamp': 1718573830.9612107,
  'window_event_timestamp': 1718573841.8384597},
 {'canonical_text': 'i',
  'children': [{'canonical_key_char': 'i',
                'id': 5718,
                'key_char': 'i',
                'key_vk': '73',
                'name': 'press',
                'screenshot_timestamp': 1718573842.3075366,
                'timestamp': 1718573842.2694087},
               {'canonical_key_char': 'h',
                'id': 5719,
                'key_char': 'h',
                'key_vk': '72',
                'name': 'release',
                'screenshot_timestamp': 1718573842.3075366,
                'timestamp': 1718573842.3449655},
               {'canonical_key_char': 'i',
                'id': 5720,
                'key_char': 'i',
                'key_vk': '73',
                'name': 'release',
                'screenshot_timestamp': 1718573842.457266,
                'timestamp': 1718573842.4092443}],
  'name': 'type',
  'reducer_names': {'keyboard'},
  'screenshot_timestamp': 1718573842.3075366,
  'text': 'i',
  'timestamp': 1718573830.9837618,
  'window_event_timestamp': 1718573841.8384597},
 {'canonical_text': '<32>',
  'children': [{'id': 5721,
                'name': 'press',
                'screenshot_timestamp': 1718573842.457266,
                'timestamp': 1718573842.5397298},
               {'id': 5722,
                'name': 'release',
                'screenshot_timestamp': 1718573842.6377387,
                'timestamp': 1718573842.6499221}],
  'name': 'type',
  'reducer_names': {'keyboard'},
  'screenshot_timestamp': 1718573842.457266,
  'text': '<space>',
  'timestamp': 1718573831.1142473,
  'window_event_timestamp': 1718573841.8384597},
 {'canonical_text': '<ctrl>-<ctrl>-<ctrl>-<ctrl>',
  'children': [{'id': 5723,
                'screenshot_timestamp': 1718573843.2517736,
                'timestamp': 1718573843.2591236},
               {'id': 5724,
                'screenshot_timestamp': 1718573843.6208365,
                'timestamp': 1718573843.7661896},
               {'id': 5725,
                'screenshot_timestamp': 1718573843.8337686,
                'timestamp': 1718573843.792407},
               {'id': 5726,
                'screenshot_timestamp': 1718573843.8337686,
                'timestamp': 1718573843.8249946}],
  'name': 'type',
  'reducer_names': {'keyboard'},
  'screenshot_timestamp': 1718573843.2517736,
  'text': '<ctrl_l>-<ctrl_l>-<ctrl_l>-<ctrl_l>',
  'timestamp': 1718573831.7234488,
  'window_event_timestamp': 1718573841.8384597}]
Preparing HTML:   0%|                                                                                                       | 0/19 [00:00<?, ?event/s]2024-06-17 03:11:30.403 | INFO     | __main__:main:282 - len(action_events)=19
Preparing HTML:   0%|                                                                                                       | 0/19 [00:00<?, ?event/s] 
2024-06-17 03:11:31.619 | ERROR    | fire.core:_CallAndUpdateTrace:681 - An error has been caught in function '_CallAndUpdateTrace', process 'MainProcess' (10428), thread 'MainThread' (24140):
Traceback (most recent call last):

  File "C:\Users\akjha\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
           |         |     -> {'__name__': '__main__', '__doc__': 'Implements visualization utilities for OpenAdapt.', '__package__': 'openadapt', '__loade...
           |         -> <code object <module> at 0x000002C3981449D0, file "D:\test\OpenAdapt\openadapt\visualize.py", line 1>
           -> <function _run_code at 0x000002C398082CB0>

  File "C:\Users\akjha\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
         |     -> {'__name__': '__main__', '__doc__': 'Implements visualization utilities for OpenAdapt.', '__package__': 'openadapt', '__loade...     
         -> <code object <module> at 0x000002C3981449D0, file "D:\test\OpenAdapt\openadapt\visualize.py", line 1>

  File "D:\test\OpenAdapt\openadapt\visualize.py", line 416, in <module>
    fire.Fire(main)
    |    |    -> <function main at 0x000002C3D0ABD3F0>
    |    -> <function Fire at 0x000002C3B38DEC20>
    -> <module 'fire' from 'C:\\Users\\akjha\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\openadapt-PrTjJyzk-py3.10\\lib\\site-pac...

  File "C:\Users\akjha\AppData\Local\pypoetry\Cache\virtualenvs\openadapt-PrTjJyzk-py3.10\lib\site-packages\fire\core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      |     |          |     |                 |        -> 'visualize.py'
                      |     |          |     |                 -> {}
                      |     |          |     -> Namespace(verbose=False, interactive=False, separator='-', completion=None, help=False, trace=False)   
                      |     |          -> []
                      |     -> <function main at 0x000002C3D0ABD3F0>
                      -> <function _Fire at 0x000002C3B39893F0>

  File "C:\Users\akjha\AppData\Local\pypoetry\Cache\virtualenvs\openadapt-PrTjJyzk-py3.10\lib\site-packages\fire\core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
    |                           -> <function _CallAndUpdateTrace at 0x000002C3B3989510>
    -> <function main at 0x000002C3D0ABD3F0>

> File "C:\Users\akjha\AppData\Local\pypoetry\Cache\virtualenvs\openadapt-PrTjJyzk-py3.10\lib\site-packages\fire\core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                |   |          -> {}
                |   -> [None, None, False, True]
                -> <function main at 0x000002C3D0ABD3F0>

  File "D:\test\OpenAdapt\openadapt\visualize.py", line 310, in main
    image = display_event(action_event)
            |             -> ActionEvent(name='move', timestamp=1718573825.0334191, recording_timestamp=1718573822.7733512, screegit push --set-upstream origin fix/visualize-screenshot-nonenshot_timestamp=171857382...
            -> <function display_event at 0x000002C3D0A96200>

  File "D:\test\OpenAdapt\openadapt\plotting.py", line 254, in display_event
    image = screenshot.image.convert("RGBA")
            -> None

AttributeError: 'NoneType' object has no attribute 'image'

To Reproduce

TODO

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions