Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onHandlerStateChange is not triggered at all🐛 #1238

Closed
3 of 4 tasks
fudr opened this issue Sep 9, 2022 · 5 comments · Fixed by #1466
Closed
3 of 4 tasks

onHandlerStateChange is not triggered at all🐛 #1238

fudr opened this issue Sep 9, 2022 · 5 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@fudr
Copy link

fudr commented Sep 9, 2022

What were you trying to do?

Hi, I download and installed exactly as described, the camera is being opened, right buttons are re-rendering the camera as expected but the capture button is not doing anything at all, the event handler onHandlerStateChange is not being called so I cant get to take pics or record videos. Using Android real device, any help please?

Reproduceable Code

{device ?
                    <CaptureButton
                    style={styles.captureButton}
                    camera={cameraRef}
                    onMediaCaptured={onMediaCaptured}
                    cameraZoom={zoom}
                    minZoom={minZoom}
                    maxZoom={maxZoom}
                    flash={supportsFlash ? flash : 'off'}
                    enabled={isCameraInitialized && isActive}
                    setIsPressingButton={setIsPressingButton}
                    />
                    :<Text>-</Text>}

What happened instead?

Capture button is not doing anything at all

Relevant log output

nothing is logged since the const onHandlerStateChanged = useCallback( 
is not being called at all

Device

Moto G60

VisionCamera Version

2.14.1

Additional information

@fudr fudr added the 🐛 bug Something isn't working label Sep 9, 2022
@fudr
Copy link
Author

fudr commented Sep 9, 2022

I also tried adding all event handlers and none of them are triggered by touching the circle button

<TapGestureHandler
      enabled={enabled}
      ref={tapHandler}
      onHandlerStateChange={onHandlerStateChanged}
      onBegan={onHandlerGestureChanged} 
      onActivated={onActivatedHandler}
      maxDelayMs={1} 
      numberOfTaps={1}
      shouldCancelWhenOutside={false}
      maxDurationMs={99999999} // <-- this prevents the TapGestureHandler from going to State.FAILED when the user moves his finger outside of the child view (to zoom)
      simultaneousHandlers={panHandler}>
      <Reanimated.View {...props} style={[buttonStyle, style]}>
        <PanGestureHandler
          enabled={enabled}
          ref={panHandler}
          failOffsetX={PAN_GESTURE_HANDLER_FAIL_X}
          activeOffsetY={PAN_GESTURE_HANDLER_ACTIVE_Y}
          onGestureEvent={onPanGestureEvent}
          simultaneousHandlers={tapHandler}>
          <Reanimated.View style={styles.flex}>
            <Reanimated.View style={[styles.shadow, shadowStyle]} />
            <View style={styles.button} />
          </Reanimated.View>
        </PanGestureHandler>
      </Reanimated.View>
    </TapGestureHandler>

@ezorfa
Copy link

ezorfa commented Sep 25, 2022

@fudr @manuelbieh I have the same issue. Did you solve this?

@Fari056
Copy link

Fari056 commented Oct 1, 2022

I have the same issue. is there any solution issue only with ### android working fine in IOS ???

@Fari056
Copy link

Fari056 commented Oct 2, 2022

I have resolved this issue by using gestureHandlerRootHOC
as per gesture handler doc.
On Android RNGH does not work by default because modals are not located under React Native Root view in native hierarchy. To fix that, components need to be wrapped with gestureHandlerRootHOC (it's no-op on iOS and web).
So wrap your components in GestureHandlerRootHOC like this and then call in return
const GestureHandlerRootHOC = gestureHandlerRootHOC(() => (

<View style={{ flex: 1 }}>

  <TapGestureHandler
    enabled={enabled}
    ref={tapHandler}
    onHandlerStateChange={onHandlerStateChanged}
    shouldCancelWhenOutside={false}
    maxDurationMs={99999999}
    simultaneousHandlers={panHandler}
  >
    <Reanimated.View {...props} style={[buttonStyle, style]}>
      <PanGestureHandler
        enabled={enabled}
        ref={panHandler}
        onHandlerStateChange={onHandlerStateChanged}
        failOffsetX={PAN_GESTURE_HANDLER_FAIL_X}
        activeOffsetY={PAN_GESTURE_HANDLER_ACTIVE_Y}
        onGestureEvent={onPanGestureEvent}
        simultaneousHandlers={tapHandler}>
        <Reanimated.View style={styles.flex}>
          <Reanimated.View style={[styles.shadow, shadowStyle]} />
          <View style={styles.button} />
        </Reanimated.View>
      </PanGestureHandler>
    </Reanimated.View>
  </TapGestureHandler>
</View>

) )
return (
//call here

)
it works in my case...

@mrousavy
Copy link
Owner

Hey! I've rewritten the entire Android codebase of VisionCamera from CameraX to Camera2 in the efforts of ✨ VisionCamera V3.

I just now completed the Camera2 rewrite and I believe the core structure is running, but there might be some edge cases to iron out. Can you try and test the PR #1674 for me to see if you can still reproduce this issue here?

Here's an instruction on how you can test that: #1674 (comment)

If the issue cannot be reproduced with that version/PR anymore, then hoorayy, I fixed it! 🎉
Otherwise please let me know and I'll keep this issue open to keep track of it.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants