mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.2k stars 1.06k forks source link

🐛 Samsung doesn't support 60 FPS #2532

Closed efstathiosntonas closed 6 months ago

efstathiosntonas commented 6 months ago

What's happening?

When trying to change between front -> back camera the camera view is flipping and then is freezing, when I tap the button to take the picture the device reboots it self.

Tried on Samsung S22 Android 14 and Xiaomi Note 8 on Android 12, on Xiaomi works as a charm. I downgraded to 3.8.2 and the issue is still there.

Tried to launch camera with front as the default camera instead of back, no luck.

react native@0.73.4 (with expo-modules-core), reanimated@3.7.0, gesture handler@2.15.0

On example app, it won't even flip the camera, it will crash

ps. had to truncate the logs by a lot, it exceeded the 65K limit of github comment.

Reproduceable Code

camera: 

import React, { ReactElement, useCallback, useEffect, useRef, useState } from "react";
import {
  GestureResponderEvent,
  Platform,
  StatusBar,
  StyleSheet,
  View
} from "react-native";
import { useIsFocused } from "@react-navigation/native";
import {
  PinchGestureHandler,
  PinchGestureHandlerGestureEvent,
  TapGestureHandler
} from "react-native-gesture-handler";
import Reanimated, {
  Extrapolate,
  interpolate,
  useAnimatedGestureHandler,
  useAnimatedProps,
  useSharedValue
} from "react-native-reanimated";
import {
  Camera as RNCamera,
  CameraRuntimeError,
  PhotoFile,
  useCameraDevice,
  useCameraFormat,
  VideoFile
} from "react-native-vision-camera";
import FontAwesome6Pro from "react-native-vector-icons/FontAwesome6Pro";
import mime from "mime";
import { openSettings } from "react-native-permissions";
import { PressableOpacity } from "react-native-pressable-opacity";
import { setRootViewBackgroundColor } from "@pnthach95/react-native-root-view-background";
import { useStyles } from "react-native-unistyles";
import { useTranslation } from "react-i18next";

import { CaptureButton } from "./views/CaptureButton";
import { CONTENT_SPACING, MAX_ZOOM_FACTOR, SAFE_AREA_PADDING } from "./Constants";
import { dimensions, notify, showErrorAlert, sleep } from "@utils/utils";
import { fullScreenAlert } from "@components/FullScreenAlert";
import { StatusBarBlurBackground } from "./views/StatusBarBlurBackground";
import { useIsForeground } from "@hooks/useIsForeground";
import { checkCameraPermission } from "@functions/image";

const ReanimatedCamera = Reanimated.createAnimatedComponent(RNCamera);
Reanimated.addWhitelistedNativeProps({
  zoom: true
});

const SCALE_FULL_ZOOM = 3;
const BUTTON_SIZE = 50;

// type Props = NativeStackScreenProps<Routes, "CameraPage">;
const Camera = ({ navigation, route }: any): ReactElement => {
  const onAddMedia = route.params.onAddMedia;
  const profile = route.params.profile;
  const onboarding = route.params.onboarding;
  const verification = route.params.verification;
  const chatGroup = route.params.chatGroup;
  const groupDetails = route.params.groupDetails;
  const forOnboardingMorePhotos = route.params.forOnboardingMorePhotos;
  const { theme } = useStyles();
  const camera = useRef<RNCamera>(null);
  const [isCameraInitialized, setIsCameraInitialized] = useState(false);
  const zoom = useSharedValue(0);
  const isPressingButton = useSharedValue(false);

  // check if camera page is active
  const isFocussed = useIsFocused();
  const isForeground = useIsForeground();
  const { t } = useTranslation("common");
  const isActive = isFocussed && isForeground;

  const [cameraPosition, setCameraPosition] = useState<"front" | "back">("back");
  const [flash, setFlash] = useState<"off" | "on">("off");
  const [enableNightMode, setEnableNightMode] = useState(false);

  const device = useCameraDevice(cameraPosition, {
    physicalDevices: ["ultra-wide-angle-camera", "wide-angle-camera", "telephoto-camera"]
  });

  const [targetFps] = useState(60);

  const screenAspectRatio = dimensions.height / dimensions.width;

  const format = useCameraFormat(device, [
    { fps: targetFps },
    { videoAspectRatio: screenAspectRatio },
    { videoResolution: "max" },
    { photoAspectRatio: screenAspectRatio },
    { photoResolution: { height: 1080, width: 1920 } }
  ]);

  const fps = Math.min(format?.maxFps ?? 1, targetFps);

  const supportsFlash = device?.hasFlash ?? false;
  const canToggleNightMode = device?.supportsLowLightBoost ?? false;

  const minZoom = device?.minZoom ?? 1;
  const maxZoom = Math.min(device?.maxZoom ?? 1, MAX_ZOOM_FACTOR);

  const cameraAnimatedProps = useAnimatedProps(() => {
    const z = Math.max(Math.min(zoom.value, maxZoom), minZoom || 0);
    return {
      zoom: z
    };
  }, [maxZoom, minZoom, zoom]);

  const setIsPressingButton = useCallback(
    (_isPressingButton: boolean) => {
      isPressingButton.value = _isPressingButton;
    },
    [isPressingButton]
  );

  // Camera callbacks
  const onError = useCallback((error: CameraRuntimeError) => {
    console.error(error);
  }, []);

  const onInitialized = useCallback(() => {
    setIsCameraInitialized(true);
  }, []);

  const changeStatusBar = useCallback(() => {
    setRootViewBackgroundColor(theme.colors.neutrals["0"]);
    if (Platform.OS === "android") {
      StatusBar.setBackgroundColor(theme.colors.neutrals["0"]);
    }
  }, [theme.colors.neutrals]);

  const onMediaCaptured = useCallback(
    async (media: (PhotoFile | VideoFile) & { uri?: string }, tp: "photo" | "video") => {
      // console.log(`Media captured! ${JSON.stringify(media)}`);

      // let compressedVideo;
      if (tp === "video") {
        // compressedVideo = await VideoCompressor.compress(
        //   media.path,
        //   {
        //     compressionMethod: "auto"
        //   },
        //   (progress) => {
        //     console.log(progress);
        //     // if (backgroundMode) {
        //     //   console.log('Compression Progress: ', progress);
        //     // } else {
        //     // //  setCompressingProgress(progress);
        //     // }
        //   }
        // );
        // await CameraRoll.save(`file://${media.path}`, {
        //   type: "video"
        // });
        // const thumbnail: Thumbnail & { uri?: string } = await createThumbnail({
        //   url: media.path,
        //   timeStamp: 1000
        // });
        // thumbnail.uri = `file://${thumbnail.path}`;
        // onAddMedia(compressedVideo, thumbnail);
      } else {
        media.uri = `file://${media.path}`;
        // @ts-ignore
        media.type = mime.getType(media.uri);
        changeStatusBar();
        if (chatGroup) {
          await onAddMedia(media);
          return navigation.navigate("CreateChatGroup", {
            data: media,
            onAddMedia
          });
        }
        if (groupDetails) {
          await onAddMedia(media);
          return navigation.goBack();
        }
        if (verification) {
          await onAddMedia(media);
          return navigation.goBack();
        }
        if (onboarding) {
          return navigation.navigate("CropImage", {
            data: media,
            forProfile: profile,
            onAddMedia
          });
        }
        if (forOnboardingMorePhotos) {
          return navigation.navigate("CropImage", {
            data: media,
            forOnboardingMorePhotos: true,
            onAddMedia
          });
        }
        if (profile) {
          return navigation.navigate("Modals", {
            screen: "CropImage",
            params: {
              data: media,
              forProfile: profile,
              onAddMedia
            }
          });
        }

        onAddMedia(media);
      }
      navigation.goBack();
    },
    [
      changeStatusBar,
      chatGroup,
      forOnboardingMorePhotos,
      groupDetails,
      navigation,
      onAddMedia,
      onboarding,
      profile,
      verification
    ]
  );

  const onFocusTap = useCallback(
    ({ nativeEvent: event }: GestureResponderEvent) => {
      if (!device?.supportsFocus) return;
      camera.current?.focus({
        x: event.locationX,
        y: event.locationY
      });
    },
    [device?.supportsFocus]
  );

  const onFlipCameraPressed = useCallback(() => {
    setCameraPosition((p) => (p === "back" ? "front" : "back"));
  }, []);

  const onToggleNightMode = useCallback(() => {
    setEnableNightMode(!enableNightMode);
  }, [enableNightMode]);

  const onFlashPressed = useCallback(() => {
    setFlash((f) => (f === "off" ? "on" : "off"));
  }, []);

  useEffect(() => {
    // Reset zoom to it's default everytime the `device` changes.
    zoom.value = device?.neutralZoom ?? 1;
  }, [zoom, device]);
  //#endregion

  useEffect(() => {
    if (Platform.OS === "android") {
      StatusBar.setBackgroundColor("#000", false);
    }
  });

  useEffect(() => {
    checkCameraPermission().catch((e: any) => {
      notify(e, "error", "User Tried to Pick an Take Camera Photo");
      if (e.message === "Required permission not granted") {
        return fullScreenAlert({
          content: t("no_camera_permission"),
          title: t("alert_title.oops"),
          buttons: [
            {
              title: t("button.close"),
              primary: false,
              onPress: () => navigation.goBack()
            },
            {
              title: t("button.settings"),
              primary: true,
              onPress: async () => {
                navigation.goBack();
                await sleep(1000);
                openSettings().catch();
              }
            }
          ]
        });
      }
      showErrorAlert(e, 414);
    });
  }, [navigation, t]);

  const onPinchGesture = useAnimatedGestureHandler<
    PinchGestureHandlerGestureEvent,
    { startZoom?: number }
  >({
    onStart: (_, context) => {
      context.startZoom = zoom.value;
    },
    onActive: (event, context) => {
      // we're trying to map the scale gesture to a linear zoom here
      const startZoom = context.startZoom ?? 0;
      const scale = interpolate(
        event.scale,
        [1 - 1 / SCALE_FULL_ZOOM, 1, SCALE_FULL_ZOOM],
        [-1, 0, 1],
        Extrapolate.CLAMP
      );
      zoom.value = interpolate(
        scale,
        [-1, 0, 1],
        [minZoom, startZoom, maxZoom],
        Extrapolate.CLAMP
      );
    }
  });

  useEffect(() => {
    setRootViewBackgroundColor(theme.colors.neutrals["0"]);
  }, [theme.colors.neutrals]);

  const onGoBack = () => {
    changeStatusBar();
    navigation.goBack();
  };

  return (
    <View style={styles.container}>
      {device != null && (
        <ReanimatedCamera
          animatedProps={cameraAnimatedProps}
          audio={false}
          device={device}
          enableZoomGesture={false}
          exposure={0}
          format={format}
          fps={fps}
          isActive={isActive}
          lowLightBoost={device.supportsLowLightBoost && enableNightMode}
          onError={onError}
          onInitialized={onInitialized}
          orientation="portrait"
          photo
          ref={camera}
          style={[StyleSheet.absoluteFill, { aspectRatio: 9 / 16 }]}
          video={false}
        />
      )}
      <CaptureButton
        camera={camera}
        cameraZoom={zoom}
        enabled={isCameraInitialized && isActive}
        flash={supportsFlash ? flash : "off"}
        maxZoom={maxZoom}
        minZoom={minZoom}
        onMediaCaptured={onMediaCaptured}
        setIsPressingButton={setIsPressingButton}
        style={styles.captureButton}
      />
      <StatusBarBlurBackground blurAmount={25} blurRadius={25} blurType="light" />
      <View style={styles.closeIcon}>
        <PressableOpacity disabledOpacity={0.4} onPress={onGoBack} style={styles.button}>
          <FontAwesome6Pro color="white" name="xmark" size={24} />
        </PressableOpacity>
      </View>
      <View style={styles.rightButtonRow}>
        <PressableOpacity
          accessibilityHint=""
          accessibilityLabel={t("accessibility.buttons.switch_camera")}
          disabledOpacity={0.4}
          onPress={onFlipCameraPressed}
          style={styles.button}
        >
          <FontAwesome6Pro color="white" name="camera-rotate" size={28} />
        </PressableOpacity>
        {canToggleNightMode ? (
          <PressableOpacity
            accessibilityHint=""
            accessibilityLabel={t("accessibility.buttons.toggle_low_light_mode")}
            disabledOpacity={0.4}
            onPress={onToggleNightMode}
            style={styles.button}
          >
            <FontAwesome6Pro
              color="white"
              name={enableNightMode ? "lightbulb" : "lightbulb-slash"}
              size={28}
            />
          </PressableOpacity>
        ) : null}
        {supportsFlash && (
          <PressableOpacity
            accessibilityHint=""
            accessibilityLabel={t("accessibility.buttons.toggle_flash {{ flash }}", {
              flash
            })}
            disabledOpacity={0.4}
            onPress={onFlashPressed}
            style={styles.button}
          >
            <FontAwesome6Pro
              color="white"
              name={flash === "on" ? "bolt" : "bolt-slash"}
              size={28}
            />
          </PressableOpacity>
        )}
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  button: {
    alignItems: "center",
    backgroundColor: "rgba(140, 140, 140, 0.3)",
    borderRadius: BUTTON_SIZE / 2,
    height: BUTTON_SIZE,
    justifyContent: "center",
    marginBottom: CONTENT_SPACING,
    width: BUTTON_SIZE
  },
  captureButton: {
    alignSelf: "center",
    bottom: SAFE_AREA_PADDING.paddingBottom,
    position: "absolute"
  },
  closeIcon: {
    left: SAFE_AREA_PADDING.paddingLeft,
    position: "absolute",
    top: SAFE_AREA_PADDING.paddingTop
  },
  container: {
    backgroundColor: "black",
    flex: 1
  },
  rightButtonRow: {
    gap: 14,
    position: "absolute",
    right: SAFE_AREA_PADDING.paddingRight + 8,
    top: SAFE_AREA_PADDING.paddingTop
  },
  text: {
    color: "white",
    fontSize: 11,
    fontWeight: "bold",
    textAlign: "center"
  }
});

export default Camera;

capture button: 

import React, {
  FC,
  memo,
  ReactElement,
  RefObject,
  useCallback,
  useMemo,
  useRef
} from "react";
import { StyleSheet, View, ViewProps } from "react-native";
import {
  PanGestureHandler,
  PanGestureHandlerGestureEvent,
  State,
  TapGestureHandler,
  TapGestureHandlerStateChangeEvent
} from "react-native-gesture-handler";
import Reanimated, {
  Easing,
  Extrapolate,
  interpolate,
  SharedValue,
  useAnimatedGestureHandler,
  useAnimatedStyle,
  useSharedValue,
  withRepeat,
  withSpring,
  withTiming
} from "react-native-reanimated";
import type {
  Camera,
  PhotoFile,
  TakePhotoOptions,
  VideoFile
} from "react-native-vision-camera";

import { CAPTURE_BUTTON_SIZE, SCREEN_HEIGHT, SCREEN_WIDTH } from "../Constants";
import { useTranslation } from "react-i18next";

const PAN_GESTURE_HANDLER_FAIL_X = [-SCREEN_WIDTH, SCREEN_WIDTH];
const PAN_GESTURE_HANDLER_ACTIVE_Y = [-2, 2];

const START_RECORDING_DELAY = 200;
const BORDER_WIDTH = CAPTURE_BUTTON_SIZE * 0.1;

interface Props extends ViewProps {
  camera: RefObject<Camera>;
  cameraZoom: SharedValue<number>;

  enabled: boolean;
  flash: "off" | "on";
  maxZoom: number;

  minZoom: number;

  onMediaCaptured: (media: PhotoFile | VideoFile, type: "photo" | "video") => void;

  setIsPressingButton: (isPressingButton: boolean) => void;
}

const _CaptureButton: FC<Props> = ({
  camera,
  onMediaCaptured,
  minZoom,
  maxZoom,
  cameraZoom,
  flash,
  enabled,
  setIsPressingButton,
  style,
  ...props
}): ReactElement => {
  const { t } = useTranslation("common");
  const pressDownDate = useRef<Date | undefined>(undefined);
  const recordingProgress = useSharedValue(0);
  const takePhotoOptions = useMemo<TakePhotoOptions>(
    () => ({
      enableShutterSound: false,
      flash: flash,
      photoCodec: "jpeg",
      quality: 85,
      qualityPrioritization: "speed",
      skipMetadata: true
    }),
    [flash]
  );
  const isPressingButton = useSharedValue(false);

  //#region Camera Capture
  const takePhoto = useCallback(async () => {
    try {
      if (camera.current == null) {
        throw new Error("Camera ref is null!");
      }

      const photo = await camera.current.takePhoto(takePhotoOptions);
      onMediaCaptured(photo, "photo");
    } catch (e) {
      console.error("Failed to take photo!", e);
    }
  }, [camera, onMediaCaptured, takePhotoOptions]);

  const stopRecording = useCallback(async () => {
    try {
      if (camera.current == null) {
        throw new Error("Camera ref is null!");
      }
      await camera.current.stopRecording();
    } catch (e) {
      console.error("failed to stop recording!", e);
    }
  }, [camera]);

  //#region Tap handler
  const tapHandler = useRef<TapGestureHandler>();
  const onHandlerStateChanged = useCallback(
    async ({ nativeEvent: event }: TapGestureHandlerStateChangeEvent) => {
      // This is the gesture handler for the circular "shutter" button.
      // Once the finger touches the button (State.BEGAN), a photo is being taken and "capture mode" is entered. (disabled tab bar)
      // Also, we set `pressDownDate` to the time of the press down event, and start a 200ms timeout. If the `pressDownDate` hasn't changed
      // after the 200ms, the user is still holding down the "shutter" button. In that case, we start recording.
      //
      // Once the finger releases the button (State.END/FAILED/CANCELLED), we leave "capture mode" (enable tab bar) and check the `pressDownDate`,
      // if `pressDownDate` was less than 200ms ago, we know that the intention of the user is to take a photo. We check the `takePhotoPromise` if
      // there already is an ongoing (or already resolved) takePhoto() call (remember that we called takePhoto() when the user pressed down), and
      // if yes, use that. If no, we just try calling takePhoto() again
      switch (event.state) {
        case State.BEGAN: {
          // enter "recording mode"
          recordingProgress.value = 0;
          isPressingButton.value = true;
          const now = new Date();
          pressDownDate.current = now;
          setTimeout(() => {
            if (pressDownDate.current === now) {
              // user is still pressing down after 200ms, so his intention is to create a video
              // startRecording();
            }
          }, START_RECORDING_DELAY);
          setIsPressingButton(true);
          return;
        }
        case State.END:
        case State.FAILED:
        case State.CANCELLED: {
          // exit "recording mode"
          try {
            if (pressDownDate.current == null) {
              throw new Error("PressDownDate ref .current was null!");
            }
            const now = new Date();
            const diff = now.getTime() - pressDownDate.current.getTime();
            pressDownDate.current = undefined;
            if (diff < START_RECORDING_DELAY) {
              // user has released the button within 200ms, so his intention is to take a single picture.
              await takePhoto();
            } else {
              // user has held the button for more than 200ms, so he has been recording this entire time.
              await stopRecording();
            }
          } finally {
            setTimeout(() => {
              isPressingButton.value = false;
              setIsPressingButton(false);
            }, 500);
          }
          return;
        }
        default:
          break;
      }
    },
    [
      isPressingButton,
      recordingProgress,
      setIsPressingButton,
      //   startRecording,
      stopRecording,
      takePhoto
    ]
  );
  //#endregion
  //#region Pan handler
  const panHandler = useRef<PanGestureHandler>();
  const onPanGestureEvent = useAnimatedGestureHandler<
    PanGestureHandlerGestureEvent,
    { offsetY?: number; startY?: number }
  >({
    onStart: (event, context) => {
      context.startY = event.absoluteY;
      const yForFullZoom = context.startY * 0.7;
      const offsetYForFullZoom = context.startY - yForFullZoom;

      // extrapolate [0 ... 1] zoom -> [0 ... Y_FOR_FULL_ZOOM] finger position
      context.offsetY = interpolate(
        cameraZoom.value,
        [minZoom, maxZoom],
        [0, offsetYForFullZoom],
        Extrapolate.CLAMP
      );
    },
    onActive: (event, context) => {
      const offset = context.offsetY ?? 0;
      const startY = context.startY ?? SCREEN_HEIGHT;
      const yForFullZoom = startY * 0.7;

      cameraZoom.value = interpolate(
        event.absoluteY - offset,
        [yForFullZoom, startY],
        [maxZoom, minZoom],
        Extrapolate.CLAMP
      );
    }
  });
  //#endregion

  const shadowStyle = useAnimatedStyle(
    () => ({
      transform: [
        {
          scale: withSpring(isPressingButton.value ? 1 : 0, {
            mass: 1,
            damping: 35,
            stiffness: 300
          })
        }
      ]
    }),
    [isPressingButton]
  );
  const buttonStyle = useAnimatedStyle(() => {
    let scale: number;
    if (enabled) {
      if (isPressingButton.value) {
        scale = withRepeat(
          withSpring(1, {
            stiffness: 100,
            damping: 1000
          }),
          -1,
          true
        );
      } else {
        scale = withSpring(0.9, {
          stiffness: 500,
          damping: 300
        });
      }
    } else {
      scale = withSpring(0.6, {
        stiffness: 500,
        damping: 300
      });
    }

    return {
      opacity: withTiming(enabled ? 1 : 0.3, {
        duration: 100,
        easing: Easing.linear
      }),
      transform: [
        {
          scale: scale
        }
      ]
    };
  }, [enabled, isPressingButton]);

  return (
    <TapGestureHandler
      enabled={enabled}
      maxDurationMs={99999999} // <-- this prevents the TapGestureHandler from going to State.FAILED when the user moves his finger outside of the child view (to zoom)
      onHandlerStateChange={onHandlerStateChanged}
      ref={tapHandler}
      shouldCancelWhenOutside={false}
      simultaneousHandlers={panHandler}
    >
      <Reanimated.View
        {...props}
        accessibilityHint=""
        accessibilityLabel={t("button.take_photo")}
        accessibilityRole="button"
        accessible
        style={[buttonStyle, style]}
      >
        <PanGestureHandler
          activeOffsetY={PAN_GESTURE_HANDLER_ACTIVE_Y}
          enabled={enabled}
          failOffsetX={PAN_GESTURE_HANDLER_FAIL_X}
          onGestureEvent={onPanGestureEvent}
          ref={panHandler}
          simultaneousHandlers={tapHandler}
        >
          <Reanimated.View style={styles.flex}>
            <Reanimated.View style={[styles.shadow, shadowStyle]} />
            <View style={styles.button} />
          </Reanimated.View>
        </PanGestureHandler>
      </Reanimated.View>
    </TapGestureHandler>
  );
};

export const CaptureButton = memo(_CaptureButton);

const styles = StyleSheet.create({
  button: {
    borderColor: "white",
    borderRadius: CAPTURE_BUTTON_SIZE / 2,
    borderWidth: BORDER_WIDTH,
    height: CAPTURE_BUTTON_SIZE,
    width: CAPTURE_BUTTON_SIZE
  },
  flex: {
    flex: 1
  },
  shadow: {
    backgroundColor: "#e34077",
    borderRadius: CAPTURE_BUTTON_SIZE / 2,
    height: CAPTURE_BUTTON_SIZE,
    position: "absolute",
    width: CAPTURE_BUTTON_SIZE
  }
});

Relevant log output

2024-02-09 11:04:44.268  4580-11690 CameraManagerGlobal     com.sec.android.sdhms                I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:44.269  1591-4564  CameraService_proxy     system_server                        I  wmi.addRefreshRateRangeForPackage minFPS = 30.001415, maxFPS = 60.0, clientName = com.APP_NAME
2024-02-09 11:04:44.269  6570-7166  CameraManagerGlobal     com.samsung.android.app.routines     I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:44.269  2246-4244  CameraManagerGlobal     com.android.systemui                 I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:44.270  7860-9202  CameraManagerGlobal     com.APP_NAME                             I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:44.328  7860-9202  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.332  7860-9202  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.335  7860-9202  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.339  7860-9202  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.429  1591-4727  SGM:GameManager         system_server                        D  identifyForegroundApp. com.APP_NAME, mCurrentUserId: 0, callerUserId: 0
2024-02-09 11:04:44.429  1591-4727  SGM:PkgDataHelper       system_server                        D  getGamePkgData(). com.APP_NAME
2024-02-09 11:04:44.445  7860-7883  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.468  7860-9202  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.498  7860-9202  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.531  7860-9202  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.541  7860-7883  BLASTBufferQueue        com.APP_NAME                             I  [SurfaceView[com.APP_NAME/com.APP_NAME.MainActivity]@0#4](f:0,a:0,s:0) onFrameAvailable the first frame is available
2024-02-09 11:04:44.546  1294-1294  SurfaceFlinger          surfaceflinger                       D  Display 4633128672291735999 HWC layers:
                                                                                                         DEVICE | 0xb400006fde1c2350 | 0102 | 0x0000022    |    0.0   50.0 1920.0 1030.0 |    0   81 1080 2196 | SurfaceView[com.APP_NAME/com.APP_NAME.MainActivity]@0(BLAST)#181
                                                                                                         DEVICE | 0xb400006fde1d7a50 | 0100 | RGBA_8888    |    0.0    0.0 1080.0 2340.0 |    0    0 1080 2340 | com.APP_NAME/com.APP_NAME.MainActivity$_7860#161
                                                                                                         DEVICE | 0xb400006fde1ad190 | 0100 | RGBA_8888    |    0.0    0.0 1080.0   81.0 |    0    0 1080   81 | StatusBar$_2246#93
                                                                                                         DEVICE | 0xb400006fde1d9650 | 0100 | RGBA_8888    |    0.0    0.0   67.0  342.0 | 1013  440 1080  782 | com.sec.android.app.launcher/com.sam[...]ce.edge.CocktailBarService$_2755#141
                                                                                                         DEVICE | 0xb400006fde1d2490 | 0100 | RGBA_8888    |    0.0    0.0 1080.0  144.0 |    0 2196 1080 2340 | NavigationBar0$_2246#88
2024-02-09 11:04:44.563  7860-7883  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:44.996  1591-2523  InsetsSourceProvider    system_server                        D  updateFakeControlTarget: fakeControl=InsetsSourceControl: {3c1c0000 mType=statusBars mSurfacePosition=Point(0, 0) mInsetsHint=Insets{left=0, top=0, right=0, bottom=0}}, fakeTarget=Window{744a66 u0 com.APP_NAME/com.APP_NAME.MainActivity}
2024-02-09 11:04:45.072  1591-1607  SGM:GameManager         system_server                        D  identifyForegroundApp. com.APP_NAME, mCurrentUserId: 0, callerUserId: 0
2024-02-09 11:04:45.072  1591-1607  SGM:PkgDataHelper       system_server                        D  getGamePkgData(). com.APP_NAME
2024-02-09 11:04:45.696  7860-14723 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:45.728  7860-8916  TrafficStats            com.APP_NAME                             D  tagSocket(181) with statsTag=0xffffffff, statsUid=-1
2024-02-09 11:04:46.137  7860-15045 TrafficStats            com.APP_NAME                             D  tagSocket(181) with statsTag=0x90000, statsUid=-1
2024-02-09 11:04:46.444  7860-7860  ViewRootIm...nActivity] com.APP_NAME                             I  ViewPostIme pointer 0
2024-02-09 11:04:46.531  7860-7860  ViewRootIm...nActivity] com.APP_NAME                             I  ViewPostIme pointer 1
2024-02-09 11:04:46.574  7860-7860  CameraView              com.APP_NAME                             I  Updating CameraSession...
2024-02-09 11:04:46.578  7860-7860  BLASTBufferQueue_Java   com.APP_NAME                             I  update, w= 1080 h= 2340 mName = ViewRootImpl@9229d71[MainActivity] mNativeObject= 0xb40000737711d810 sc.mNativeObject= 0xb400007497102010 format= -3 caller= android.view.ViewRootImpl.updateBlastSurfaceIfNeeded:2968 android.view.ViewRootImpl.relayoutWindow:9998 android.view.ViewRootImpl.performTraversals:4056 android.view.ViewRootImpl.doTraversal:3239 android.view.ViewRootImpl$TraversalRunnable.run:11197 android.view.Choreographer$CallbackRecord.run:1650 
2024-02-09 11:04:46.578  1591-2524  WindowManager           system_server                        V  Relayout Window{744a66 u0 com.APP_NAME/com.APP_NAME.MainActivity}: viewVisibility=0 req=1080x2340 d0
2024-02-09 11:04:46.578  7860-7860  ViewRootIm...nActivity] com.APP_NAME                             I  Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=0 res=0x0 s={true 0xb400007507130d70} ch=false seqId=0
2024-02-09 11:04:46.578  7860-7860  ViewRootIm...nActivity] com.APP_NAME                             I  updateBoundsLayer: t=android.view.SurfaceControl$Transaction@b2b7452 sc=Surface(name=Bounds for - com.APP_NAME/com.APP_NAME.MainActivity@0)/@0x85db323 frame=177
2024-02-09 11:04:46.579  7860-9757  CameraSession           com.APP_NAME                             I  configure { ... }: Waiting for lock...
2024-02-09 11:04:46.579  7860-9757  CameraSession           com.APP_NAME                             I  configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true)
2024-02-09 11:04:46.579  7860-9757  CameraSession           com.APP_NAME                             I  Configuring inputs for CameraSession...
2024-02-09 11:04:46.580  7860-9757  CameraView              com.APP_NAME                             I  invokeOnStopped()
2024-02-09 11:04:46.580  7860-9757  Persistent...ureSession com.APP_NAME                             D  --> setInput(1)
2024-02-09 11:04:46.582  7860-7860  ViewRootIm...nActivity] com.APP_NAME                             I  registerCallbackForPendingTransactions
2024-02-09 11:04:46.584  7860-7860  ViewRootIm...nActivity] com.APP_NAME                             I  registerCallbackForPendingTransactions
2024-02-09 11:04:46.586  7860-9165  ViewRootIm...nActivity] com.APP_NAME                             I  mWNT: t=0xb4000074e7dd9e50 mBlastBufferQueue=0xb40000737711d810 fn= 177 caller= android.view.ViewRootImpl$6.onFrameDraw:5539 android.view.ViewRootImpl$2.onFrameDraw:2103 android.view.ThreadedRenderer$1.onFrameDraw:788 
2024-02-09 11:04:46.634  7860-9164  ViewRootIm...nActivity] com.APP_NAME                             I  mWNT: t=0xb4000074e7dd9090 mBlastBufferQueue=0xb40000737711d810 fn= 178 caller= android.view.ViewRootImpl$6.onFrameDraw:5539 android.view.ViewRootImpl$2.onFrameDraw:2103 android.view.ThreadedRenderer$1.onFrameDraw:788 
2024-02-09 11:04:46.679  1403-14150 CameraService           cameraserver                         I  finishCameraStreamingOps: finish camera streaming ops, package name = com.APP_NAME, client UID = 10718
2024-02-09 11:04:46.680  1403-14150 CameraServ...oxyWrapper cameraserver                         I  updateProxyDeviceState: notifyCameraState for Camera ID 0, newState 2, facing 0, clientName com.APP_NAME, apiLevel 2
2024-02-09 11:04:46.680  1591-4668  CameraManagerGlobal     system_server                        I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.680  5643-5658  CameraManagerGlobal     com.samsung.android.honeyboard       I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.680  2657-14161 CameraManagerGlobal     com.sec.sve                          I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.681  4580-5244  CameraManagerGlobal     com.sec.android.sdhms                I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.681  7860-15130 CameraManagerGlobal     com.APP_NAME                             I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.681  8377-8477  CameraManagerGlobal     com.samsung.android.easysetup        I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.681  1591-2933  CameraService_proxy     system_server                        I  wmi.removeRefreshRateRangeForPackage clientName = com.APP_NAME
2024-02-09 11:04:46.681  6570-12531 CameraManagerGlobal     com.samsung.android.app.routines     I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.681  2246-3385  CameraManagerGlobal     com.android.systemui                 I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.682  9548-10126 CameraManagerGlobal     com...sung.android.vtcamerasettings  I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.682 13737-13957 CameraManagerGlobal     com.android.cameraextensions         I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.850  1403-14370 CameraServ...oxyWrapper cameraserver                         I  updateProxyDeviceState: notifyCameraState for Camera ID 0, newState 3, facing 0, clientName com.APP_NAME, apiLevel 2
2024-02-09 11:04:46.852  1403-14370 CameraService           cameraserver                         I  finishCameraOps: Finish camera ops, package name = com.APP_NAME, client UID = 10718
2024-02-09 11:04:46.853  2246-3385  CameraManagerGlobal     com.android.systemui                 I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.853  9548-10126 CameraManagerGlobal     com...sung.android.vtcamerasettings  I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.853  2657-14161 CameraManagerGlobal     com.sec.sve                          I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.853  7860-15130 CameraManagerGlobal     com.APP_NAME                             I  postSingleUpdate device: camera id 0 status STATUS_PRESENT
2024-02-09 11:04:46.853  5643-5658  CameraManagerGlobal     com.samsung.android.honeyboard       I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.853  7860-15130 CameraManagerGlobal     com.APP_NAME                             I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.853  7860-9770  CameraDevices           com.APP_NAME                             I  Camera #0 is now available.
2024-02-09 11:04:46.854  8377-8477  CameraManagerGlobal     com.samsung.android.easysetup        I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.854  6570-12531 CameraManagerGlobal     com.samsung.android.app.routines     I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.854  4580-6421  CameraManagerGlobal     com.sec.android.sdhms                I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.855  7860-9757  CameraSession           com.APP_NAME                             I  Destroying previous outputs...
2024-02-09 11:04:46.855  7860-9757  SurfaceOutput           com.APP_NAME                             I  Closing 1920x1080 PHOTO ImageReader..
2024-02-09 11:04:46.855  7860-9758  com.APP_NAME                com.APP_NAME                             W  Long monitor contention with owner mrousavy/VisionCamera.main (9757) at void android.hardware.camera2.impl.CameraDeviceImpl.flush()(CameraDeviceImpl.java:1445) waiters=0 in void android.hardware.camera2.impl.CameraDeviceImpl$4.run() for 273ms
2024-02-09 11:04:46.856  1591-4785  CameraManagerGlobal     system_server                        I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.856  7860-9757  CameraSession           com.APP_NAME                             I  Creating outputs for Camera #1...
2024-02-09 11:04:46.857 13737-13957 CameraManagerGlobal     com.android.cameraextensions         I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.858  7860-9757  CameraSession           com.APP_NAME                             I  Adding 1920x1080 Photo Output in JPEG...
2024-02-09 11:04:46.860  7860-9757  CameraSession           com.APP_NAME                             I  Adding 1920x1080 Preview Output...
2024-02-09 11:04:46.861  7860-7860  PreviewView             com.APP_NAME                             I  Setting PreviewView Surface Size to 1920x1080...
2024-02-09 11:04:46.861  7860-9757  Persistent...ureSession com.APP_NAME                             D  --> setOutputs([PHOTO (1920x1080 in JPEG), PREVIEW (1920 x 1080)])
2024-02-09 11:04:46.861  7860-9757  CameraSession           com.APP_NAME                             I  Successfully configured Session with 2 outputs for Camera #1!
2024-02-09 11:04:46.861  7860-9757  Persistent...ureSession com.APP_NAME                             D  --> setRepeatingRequest(...)
2024-02-09 11:04:46.861  7860-9757  Persistent...ureSession com.APP_NAME                             D  --> setIsActive(true)
2024-02-09 11:04:46.861  7860-9757  Persistent...ureSession com.APP_NAME                             D  Configure() with isActive: true, ID: 1, device: null, session: null
2024-02-09 11:04:46.861  7860-9757  Persistent...ureSession com.APP_NAME                             I  Creating new device...
2024-02-09 11:04:46.861  7860-9757  CameraManager           com.APP_NAME                             I  Camera #1: Opening...
2024-02-09 11:04:46.863  1403-1584  CameraService           cameraserver                         I  CameraService::connect call (PID 7860 "com.APP_NAME", camera ID 1) and Camera API version 2
2024-02-09 11:04:46.866  1403-1584  CameraService           cameraserver                         I  isUidActiveLocked E: uid 10718, callingPackage com.APP_NAME, isRegistered true
2024-02-09 11:04:46.866  1403-1584  CameraService           cameraserver                         I  isUidActiveLocked X: uid 10718, callingPackage com.APP_NAME, isActive true.
2024-02-09 11:04:46.867  1403-1584  CameraService           cameraserver                         I  CameraService::validateClientPermissionsLocked is ok : calling pid 7860, calling uid 10718, client com.APP_NAME , cameraservice pid=1403, device user 0, currently allowed device users: 0
2024-02-09 11:04:46.868  1403-1584  Camera2ClientBase       cameraserver                         I  Camera 1: Opened. Client: com.APP_NAME (PID 7860, UID 10718)
2024-02-09 11:04:46.868  1403-1584  CameraService           cameraserver                         I  isNoSALoggingPackage: com.APP_NAME is a third party package.
2024-02-09 11:04:46.869  1403-1584  CameraService           cameraserver                         I  service.camera.client set to com.APP_NAME
2024-02-09 11:04:46.869  2657-2670  CameraManagerGlobal     com.sec.sve                          I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.869  2246-2270  CameraManagerGlobal     com.android.systemui                 I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.869  7860-7883  CameraManagerGlobal     com.APP_NAME                             I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.869  1591-4771  CameraManagerGlobal     system_server                        I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.869  5643-6300  CameraManagerGlobal     com.samsung.android.honeyboard       I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.870  9548-10126 CameraManagerGlobal     com...sung.android.vtcamerasettings  I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.870  8377-8423  CameraManagerGlobal     com.samsung.android.easysetup        I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.870 13737-13915 CameraManagerGlobal     com.android.cameraextensions         I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.870  6570-7166  CameraManagerGlobal     com.samsung.android.app.routines     I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.870  4580-8801  CameraManagerGlobal     com.sec.android.sdhms                I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPENING for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.875  1403-1584  CameraService           cameraserver                         I  startCameraOps: Start camera ops, package name = com.APP_NAME, client UID = 10718
2024-02-09 11:04:46.879  7860-7883  CameraManagerGlobal     com.APP_NAME                             I  postSingleUpdate device: camera id 1 status STATUS_NOT_AVAILABLE
2024-02-09 11:04:46.880  7860-9770  CameraDevices           com.APP_NAME                             I  Camera #1 is now unavailable.
2024-02-09 11:04:46.887  1259-1788  Unihal                  ven...amera.provider@4.0-service_64  I  UniHal3InterfaceEntry.cpp: uni_set_parameters: 456: set_parameters : pkgName=com.APP_NAME;
2024-02-09 11:04:46.887  1259-1788  ExynosCame...rationsSec ven...amera.provider@4.0-service_64  I  [CAM(1)][Front_0]-(checkClientPackageName[2714]):packageName (com.APP_NAME) cameraClient (0) m_isLowPowerApp (0) packageNameHint(0xffffffff)
2024-02-09 11:04:46.887  1403-1584  CameraServ...oxyWrapper cameraserver                         I  updateProxyDeviceState: notifyCameraState for Camera ID 1, newState 0, facing 1, clientName com.APP_NAME, apiLevel 2
2024-02-09 11:04:46.888  1403-1584  CameraService           cameraserver                         I  isNoSALoggingPackage: com.APP_NAME is a third party package.
2024-02-09 11:04:46.888  2246-2270  CameraManagerGlobal     com.android.systemui                 I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.888 13737-13915 CameraManagerGlobal     com.android.cameraextensions         I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.888  5643-6300  CameraManagerGlobal     com.samsung.android.honeyboard       I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.888  2657-2669  CameraManagerGlobal     com.sec.sve                          I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.888  6570-12531 CameraManagerGlobal     com.samsung.android.app.routines     I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.888  1591-2933  CameraManagerGlobal     system_server                        I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.888  4580-6421  CameraManagerGlobal     com.sec.android.sdhms                I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.889  9548-10126 CameraManagerGlobal     com...sung.android.vtcamerasettings  I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.890  8377-8423  CameraManagerGlobal     com.samsung.android.easysetup        I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.890  7860-9758  CameraManager           com.APP_NAME                             I  Camera #1: Opened!
2024-02-09 11:04:46.891  7860-7883  CameraManagerGlobal     com.APP_NAME                             I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_OPEN for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:46.891  7860-9757  Persistent...ureSession com.APP_NAME                             I  Creating new session...
2024-02-09 11:04:46.895  7860-9757  CreateCaptureSession    com.APP_NAME                             I  Camera #1: Creating Capture Session #3... (Hardware Level: 0 | Outputs: [PHOTO (1920x1080 in JPEG), PREVIEW (1920 x 1080)])
2024-02-09 11:04:46.895  7860-9757  CreateCaptureSession    com.APP_NAME                             I  Using new API (>=28)
2024-02-09 11:04:47.022  7860-9758  CreateCaptureSession    com.APP_NAME                             I  Camera #1: Successfully created CameraCaptureSession #3!
2024-02-09 11:04:47.022  7860-9757  Persistent...ureSession com.APP_NAME                             D  Updating repeating request...
2024-02-09 11:04:47.026  1403-15214 CameraService           cameraserver                         I  startCameraStreamingOps: Start camera streaming ops, package name = com.APP_NAME, client UID = 10718
2024-02-09 11:04:47.027  7860-9757  Persistent...ureSession com.APP_NAME                             D  Configure() done! isActive: true, ID: 1, device: android.hardware.camera2.impl.CameraDeviceImpl@481e56f, session: android.hardware.camera2.impl.CameraCaptureSessionImpl@f65f705
2024-02-09 11:04:47.027  7860-9757  CameraSession           com.APP_NAME                             I  configure { ... }: Completed CameraSession Configuration! (isActive: true, isRunning: true)
2024-02-09 11:04:47.027  7860-9757  CameraView              com.APP_NAME                             I  invokeOnStarted()
2024-02-09 11:04:47.027  1403-15214 CameraServ...oxyWrapper cameraserver                         I  updateProxyDeviceState: notifyCameraState for Camera ID 1, newState 1, facing 1, clientName com.APP_NAME, apiLevel 2
2024-02-09 11:04:47.027  7860-9757  CameraView              com.APP_NAME                             I  invokeOnInitialized()
2024-02-09 11:04:47.027  5643-6300  CameraManagerGlobal     com.samsung.android.honeyboard       I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.027  2246-2270  CameraManagerGlobal     com.android.systemui                 I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.028  4580-5244  CameraManagerGlobal     com.sec.android.sdhms                I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.028  2657-2669  CameraManagerGlobal     com.sec.sve                          I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.028  7860-7883  CameraManagerGlobal     com.APP_NAME                             I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.028  1591-4794  CameraService_proxy     system_server                        I  wmi.addRefreshRateRangeForPackage minFPS = 60.0, maxFPS = 60.0, clientName = com.APP_NAME
2024-02-09 11:04:47.028  9548-10126 CameraManagerGlobal     com...sung.android.vtcamerasettings  I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.028 13737-13915 CameraManagerGlobal     com.android.cameraextensions         I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.028  1591-1669  SensorPrivacyService    system_server                        D  onOpNoted  com.APP_NAME  code=26  uid=10718
2024-02-09 11:04:47.029  1591-1607  CameraManagerGlobal     system_server                        I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.029  8377-8423  CameraManagerGlobal     com.samsung.android.easysetup        I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.029  6570-12531 CameraManagerGlobal     com.samsung.android.app.routines     I  Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_ACTIVE for client com.APP_NAME API Level 2 User Id 0
2024-02-09 11:04:47.063  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.103  1294-1294  SurfaceFlinger          surfaceflinger                       D  Display 4633128672291735999 HWC layers:
                                                                                                         DEVICE | 0xb400006fde1a4050 | 0102 | 0x0000022    |    0.0   50.0 1920.0 1030.0 |    0   81 1080 2196 | SurfaceView[com.APP_NAME/com.APP_NAME.MainActivity]@0(BLAST)#181
                                                                                                         DEVICE | 0xb400006fde1d7a50 | 0100 | RGBA_8888    |    0.0    0.0 1080.0 2340.0 |    0    0 1080 2340 | com.APP_NAME/com.APP_NAME.MainActivity$_7860#161
                                                                                                         DEVICE | 0xb400006fde1ad190 | 0100 | RGBA_8888    |    0.0    0.0 1080.0   81.0 |    0    0 1080   81 | StatusBar$_2246#93
                                                                                                         DEVICE | 0xb400006fde1d9650 | 0100 | RGBA_8888    |    0.0    0.0   67.0  342.0 | 1013  440 1080  782 | com.sec.android.app.launcher/com.sam[...]ce.edge.CocktailBarService$_2755#141
                                                                                                         DEVICE | 0xb400006fde1d2490 | 0100 | RGBA_8888    |    0.0    0.0 1080.0  144.0 |    0 2196 1080 2340 | NavigationBar0$_2246#88
                                                                                                         DEVICE | 0xb400006fde1dd390 | 0140 | RGBA_8888    |    0.0    0.0 1080.0   81.0 |    0    0 1080   81 | ScreenDecorOverlay$_2246#188
2024-02-09 11:04:47.171  1294-1579  SurfaceFlinger          surfaceflinger                       I  id=162 Removed Surface(name=744a66 com.APP_NAME/com.APP_NAME.MainActivity)/@0xeff81c - animation-leash of starting_reveal#162 (111)
2024-02-09 11:04:47.183  1294-1294  Layer                   surfaceflinger                       I  id=162 Destroyed Surface(name=744a66 com.APP_NAME/com.APP_NAME.MainActivity)/@0xeff81c - animation-leash of starting_reveal#162
2024-02-09 11:04:47.216  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.220  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.222  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.224  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.227  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.289  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.305  7860-15130 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.354  7860-7883  com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.489  7860-14723 com.APP_NAME                com.APP_NAME                             D  [is_supported_usage] IMPLEMENTATION_DEFINED must not have CPU usage, [0x20933]
2024-02-09 11:04:47.493  1591-2524  InsetsSourceProvider    system_server                        D  updateControlForTarget: control=InsetsSourceControl: {3c1c0000 mType=statusBars initiallyVisible mSurfacePosition=Point(0, 0) mInsetsHint=Insets{left=0, top=81, right=0, bottom=0}}, target=Window{744a66 u0 com.APP_NAME/com.APP_NAME.MainActivity}, from=com.android.server.wm.InsetsStateController.onControlTargetChanged:358 com.android.server.wm.InsetsStateController.onBarControlTargetChanged:324 com.android.server.wm.InsetsPolicy.updateBarControlTarget:172 com.android.server.wm.InsetsPolicy.updateSystemBars:788 com.android.server.wm.DisplayPolicy.updateSystemBarsLw:3358 
2024-02-09 11:04:47.496  7860-7860  InsetsSourceConsumer    com.APP_NAME                             D  applyRequestedVisibilityToControl: visible=true, type=1

After tapping the button, phone reboots.

2024-02-09 11:14:21.809 18108-18108 CameraView              com.APP_NAME                             D  Finding view 1053...
2024-02-09 11:14:21.810 18108-18108 CameraView              com.APP_NAME                             D  Found view 1053!
2024-02-09 11:14:21.811 18108-18412 CameraView.takePhoto    com.APP_NAME                             I  Taking photo... Options: {skipMetadata=true, photoCodec=jpeg, enableShutterSound=false, qualityPrioritization=speed, quality=85.0, flash=off}
2024-02-09 11:14:21.812 18108-18412 CameraSession           com.APP_NAME                             I  Photo capture 0/3 - preparing capture request (1920x1080)...
2024-02-09 11:14:21.820 18108-18412 CameraSession           com.APP_NAME                             I  Photo capture 1/3 - starting capture...

Camera Device

front: 

{
  "formats": [],
  "sensorOrientation": "landscape-left",
  "hardwareLevel": "full",
  "maxZoom": 10,
  "minZoom": 0.6000000238418579,
  "maxExposure": 20,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "ultra-wide-angle-camera",
    "wide-angle-camera",
    "telephoto-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": true,
  "isMultiCam": true,
  "minFocusDistance": 10,
  "minExposure": -20,
  "name": "BACK (0)",
  "hasFlash": true,
  "hasTorch": true,
  "position": "back",
  "id": "0"
}

back: 

{
  "formats": [],
  "sensorOrientation": "landscape-right",
  "hardwareLevel": "limited",
  "maxZoom": 4,
  "minZoom": 1,
  "maxExposure": 20,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": true,
  "isMultiCam": false,
  "minFocusDistance": 20,
  "minExposure": -20,
  "name": "FRONT (1)",
  "hasFlash": false,
  "hasTorch": false,
  "position": "front",
  "id": "1"
}

Device

Samsung S22 Android 14

VisionCamera Version

3.9.0-beta.3 and 3.8.2

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

efstathiosntonas commented 6 months ago

when I removed the fps prop the issue went away.

mrousavy commented 6 months ago

Thanks for the bug report, but the reproduceable code is way too much. Can you please try to reproduce it in the example app instead?

efstathiosntonas commented 6 months ago

hi, it's happening on example too, I've tested it against Samsung S22 Android 14.

edit: tested it on beta 3

mrousavy commented 6 months ago

Okay yea I just read your comment about fps - I know about this issue, and I honestly don't know what to do here. Samsung is saying their phones can do 60 FPS in the API, but when you try to use 60 FPS it crashes. They are messing it up here, there's nothing I can do except explicitly disabling 60 FPS on Samsung devices.

Just to clarify; does it also crash if just set fps={30}, or only something higher than 30?

efstathiosntonas commented 6 months ago

thanks for the heads up, will check with 30 in a while but it should be the default if the prop isn't provided, right?

mrousavy commented 6 months ago

Technically not, null means it won't set AE_EXPOSURE_DURATION, whereas 30 means it will set it to 30.

efstathiosntonas commented 6 months ago

fps={30} won't crash it.

mrousavy commented 6 months ago

Yea okay, then it definitely is the same issue that I am already aware of. It's so lame that Samsung simply lies in CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES - it contains 60 FPS, but doesn't actually support 60 FPS.

efstathiosntonas commented 6 months ago

I wished they were lame only on that part lol!

I think the issue title should be ...in front camera

mrousavy commented 6 months ago

Just to double check if I am understanding this correctly - all values listed here are supported, right? Or only values here, that are also in CamcorderProfile.videoFrameRate?

Screenshot 2024-02-13 at 15 38 52

mrousavy commented 6 months ago

Can you try with a really low res format and see if that works at 60 FPS?

const format = useCameraFormat(device, [
  { videoResolution: { width: 100, height: 100 }
])
efstathiosntonas commented 6 months ago

on back camera it throwed this:

fps={60}

 ERROR  [format/invalid-fps: [format/invalid-fps] The given format cannot run at 60 FPS! Make sure your FPS is lower than `format.maxFps` but higher than `format.minFps`.]

when switching to front no error but the screen is black, tried setting format to 400x400, same thing.

mrousavy commented 6 months ago

Hey - I just released VisionCamera 3.9.0-beta.4 which probably fixes this issue - can you try that latest beta and let me know? :)

efstathiosntonas commented 6 months ago

it wont crash after setting fps to 60. Thanks Marc, keep it up!

thegreatzeus commented 4 months ago

@mrousavy I can confirm this issue still exists. I have tested v3.9.0-beta.4 and the latest release v3.9.2 on Galaxy S23 Ultra and Galaxy S22 both running Android 14. 60 FPS is available on both devices' front and back cameras, but VisionCamera is limited to 30 FPS.

Example code:

import { View, Text } from "react-native";
import { useEffect } from 'react';
import { useCameraFormat, useCameraDevice } from "react-native-vision-camera";

export default function App() {
  const device = useCameraDevice("front");
  const format = useCameraFormat(device, [
    { fps: 60 }
  ]);

  useEffect(() => {
    console.log(format)
  }, [format]);

  return (
    <View>
      <Text>Test</Text>
    </View>
  );
}

Outputs:

{
  "autoFocusSystem": "contrast-detection",
  "fieldOfView": 80.25568970571118,
  "maxFps": 30,
  "maxISO": 3200,
  "maxZoom": 8,
  "minFps": 1,
  "minISO": 50,
  "photoHeight": 2736,
  "photoWidth": 3648,
  "pixelFormats": [
    "yuv",
    "native"
  ],
  "supportsDepthCapture": false,
  "supportsPhotoHdr": false,
  "supportsVideoHdr": false,
  "videoHeight": 1440,
  "videoStabilizationModes": [
    "off",
    "off"
  ],
  "videoWidth": 1920
}
mrousavy commented 4 months ago

Again, this is because of Android. Not because of VisionCamera. Samsung locks 60 FPS for only their own app.

laxminarayana-capgemini commented 2 months ago

Hi @mrousavy, Is there any solutions for this. I trying to run in several Android mobiles. Most of the mobiles are giving maxFps as 30 only. Please can you suggest any solutions? Thanks.

mrousavy commented 2 months ago

Dude did you read my comment directly above your comment?