    frame = "wideRoadCameraState" if TICI else "roadCameraState"
    front_frame = "driverCameraState" if front_camera_allowed else None
    focus_perc_threshold = 0. if TICI else 10 / 12.
  
    rear, front = get_snapshots(frame, front_frame, focus_perc_threshold)
    managed_processes['camerad'].stop()
  
    params.put_bool("IsTakingSnapshot", False)
    set_offroad_alert("Offroad_IsTakingSnapshot", False)
  
    if not front_camera_allowed:
 
</s> remove   managed_processes['camerad'].start()
  frame = "wideRoadCameraState" if TICI else "roadCameraState"
  front_frame = "driverCameraState" if front_camera_allowed else None
  focus_perc_threshold = 0. if TICI else 10 / 12.
 </s> add   try:
    HARDWARE.set_power_save(False)
    managed_processes['camerad'].start()
    frame = "wideRoadCameraState" if TICI else "roadCameraState"
    front_frame = "driverCameraState" if front_camera_allowed else None
    focus_perc_threshold = 0. if TICI else 10 / 12. </s> remove   params.put_bool("IsTakingSnapshot", False)
  set_offroad_alert("Offroad_IsTakingSnapshot", False)
 </s> add     params.put_bool("IsTakingSnapshot", False)
    set_offroad_alert("Offroad_IsTakingSnapshot", False) </s> remove from selfdrive.hardware import TICI
 </s> add from selfdrive.hardware import HARDWARE, TICI
    rear, front = get_snapshots(frame, front_frame, focus_perc_threshold)
  finally:
    managed_processes['camerad'].stop()
    HARDWARE.set_power_save(True)
    frame = "wideRoadCameraState" if TICI else "roadCameraState"
    front_frame = "driverCameraState" if front_camera_allowed else None
    focus_perc_threshold = 0. if TICI else 10 / 12.
  
    rear, front = get_snapshots(frame, front_frame, focus_perc_threshold)
  finally:
    managed_processes['camerad'].stop()
    HARDWARE.set_power_save(True)
    rear, front = get_snapshots(frame, front_frame, focus_perc_threshold)
  finally:
    managed_processes['camerad'].stop()
    HARDWARE.set_power_save(True)
  
    params.put_bool("IsTakingSnapshot", False)
    set_offroad_alert("Offroad_IsTakingSnapshot", False)
  
    if not front_camera_allowed:
keep keep keep keep replace replace keep keep keep keep keep
 fix snapshot camerad crash due to core affinity setting (#22648)

Co-authored-by: Comma Device <device@comma.ai> 
selfdrive/camerad/snapshot/snapshot.py