colour-blind-camera icon indicating copy to clipboard operation
colour-blind-camera copied to clipboard

Serious performance issue

Open Sp00nyMan opened this issue 3 years ago • 0 comments

When creating a new capture session in the method _java_capture_session_callback the _update_preview method is being scheduled to run repetedly. However, if we, for some reason, restart the camera (for example, in the on_resume method), the method is scheduled again and now is called twice. To fix this issue we can save the return of Clock.schedule_interval(self._update_preview, 0) and cancel is in the close() method

def _java_capture_session_callback(self, *args, **kwargs):
    event = MyCaptureSessionCallback.camera_capture_event.toString()
    logger.info("CALLBACK: capture event {}".format(event))

    self.java_capture_session = MyCaptureSessionCallback.camera_capture_session

    if event == "READY":
        logger.info("Doing READY actions")
        self.java_capture_session.setRepeatingRequest(self.java_capture_request.build(), None, None)
        self.clock_event = Clock.schedule_interval(self._update_preview, 0) #Saving the event object so we can cancel it
def close(self):
    self.java_camera_device.close()
    if self.clock_event is not None:
        self.clock_event.cancel()

Sp00nyMan avatar Feb 17 '22 11:02 Sp00nyMan