You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i have a page. under it i added my custom modal normally i used it elsewhere. problem is , inside that modal i try to implement camera to open. but app goes crashed evetime i opened up the modal. and it is purely due to the usage of camera inside modal. all permissions i checked everything works fine. since no logs , errors , warnings i saw. just app crash.
Reproduceable Code
<ModalCompisModalVisible={qrSacannerModal}closeModal={()=>{setVal('');setScanned(false);setVerify(false);setDetailsModal(false);setqrSacannerModal(false);}}><Viewstyle={{marginBottom: -50,bottom: 40,}}><Textstyle={{...styling.title,alignSelf: 'center',fontSize: 30}}>{/* {isTorch ? 'Scan QR Code' : 'Result'} */}
Scan QR code
</Text>{/* {isTorch && ( <> */}<Textstyle={{
...styling.description,alignSelf: 'center',color: 'gray',fontFamily: Fonts.Regular,textAlign: 'center',fontSize: 12,width: '90%',}}>
Ensure Camera remain still. point camera to the qr code wait a
while for scanner to catch up code
</Text><TouchableOpacitystyle={{alignSelf: 'flex-end',zIndex: 99}}onPress={()=>setTorch(prev=>!prev)}><Ioniconsname={torch ? 'flash-outline' : 'flash-off-outline'}style={{color: Colors.white,top: 26,fontSize: 22,marginRight: 10,// ...IconStyling,}}/></TouchableOpacity>{/* </> */}{/* )} */}</View><Viewstyle={{height: '67%',width: '100%',alignSelf: 'center',marginBottom: -180,}}><CodeScannerPageonPress={()=>setqrSacannerModal(false)}torch={torch}// OnVal={handleVal}OnVal={inpt=>handleVal(inpt)}// isTorch={handleTorch}// setIsDetails={val => setIsDetails(val)}qrSacannerModal={qrSacannerModal}/></View></></ModalComp>//and separate component i used inside of that modal which actually contains //camera.constrequestCameraPermissions=async()=>{if(Platform.OS==='android'){constgranted=awaitPermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA,{title: 'Camera Permission',message: 'We need access to your camera to scan QR codes',buttonPositive: 'OK',},);returngranted===PermissionsAndroid.RESULTS.GRANTED;}else{conststatus=awaitCamera.requestCameraPermission();returnstatus==='authorized';}};exportfunctionCodeScannerPage({
navigation,
onPress,
torch,
OnVal,
qrSacannerModal,}){const[hasPermission,setHasPermission]=useState(false);const[device,setDevice]=useState(null);constisShowingAlert=useRef(false);constshowCodeAlert=(value,onDismissed)=>{constbuttons=[{text: 'Close',style: 'cancel',onPress: onDismissed}];OnVal(value);};constfetchPermission=async()=>{constpermission=awaitrequestCameraPermissions();if(permission){setHasPermission(true);}else{Alert.alert('Blockshare Camera Permission Not Granted','You need to grant this app permission to use the camera to scan QR code',[{text: 'Cancel',onPress: onPress},{text: 'Grant',onPress: ()=>Linking.openSettings()},],);}};useEffect(()=>{fetchPermission();return()=>{// Cleanup function when component unmounts or modal closes// Stop any ongoing scanning or release camera resources here// For example:// Stop camera scanning or other ongoing processes// Dispose of any event listeners or subscriptions// Reset any state variables used for camera management// Example:// stopScanning();// disposeCamera();// resetStateVariables();setHasPermission(false);setDevice(null);onPress();};},[]);useEffect(()=>{constgetCameraDevice=async()=>{constavailableDevices=awaitCamera.getAvailableCameraDevices();if(availableDevices.length>0){constbackCamera=availableDevices.find(device=>device.position==='back',);setDevice(backCamera);}else{console.log('No camera devices available');}};if(hasPermission){getCameraDevice();}},[hasPermission,device]);constonCodeScanned=useCallback(codes=>{constvalue=codes[0]?.value;if(value==null||isShowingAlert.current)return;showCodeAlert(value,()=>{isShowingAlert.current=false;});isShowingAlert.current=true;},[]);constcodeScanner=useCodeScanner({codeTypes: ['qr','ean-13'],
onCodeScanned,});if(!hasPermission){return(<Viewstyle={styles.container}><Textstyle={styling.title}>Requesting Camera Permission...</Text></View>);}if(!device){return(<Viewstyle={styles.container}><Textstyle={styling.title}>No Camera Device Available</Text>{/* <Button title="Retry" onPress={fetchPermission} /> */}</View>);}return(<Viewstyle={styles.container}><Textstyle={styling.title}>Scan QR Code</Text>{qrSacannerModal&&hasPermission&&device&&(<Camerastyle={StyleSheet.absoluteFill}device={device}isActive={true}codeScanner={codeScanner}torch={torch ? 'on' : 'off'}enableZoomGesture={true}/>)}</View>);}
Relevant log output
No errors just app crash when try to use camera inside modal.
Camera Device
back camera
Device
Techno Camon 18T
VisionCamera Version
3.8.2
Can you reproduce this issue in the VisionCamera Example app?
I didn't try (鈿狅笍 your issue might get ignored & closed if you don't try this)
Additional information
I am using Expo
I have enabled Frame Processors (react-native-worklets-core)
Looks like 'ya left out some information!
Make sure to add enough details to the following section:
Camera Device
Note
New features, bugfixes, updates and other improvements are all handled mostly by @mrousavy in his free time.
To support @mrousavy, please consider 馃挅 sponsoring him on GitHub 馃挅.
Sponsored issues will be prioritized.
What's happening?
i have a page. under it i added my custom modal normally i used it elsewhere. problem is , inside that modal i try to implement camera to open. but app goes crashed evetime i opened up the modal. and it is purely due to the usage of camera inside modal. all permissions i checked everything works fine. since no logs , errors , warnings i saw. just app crash.
Reproduceable Code
Relevant log output
Camera Device
back camera
Device
Techno Camon 18T
VisionCamera Version
3.8.2
Can you reproduce this issue in the VisionCamera Example app?
I didn't try (鈿狅笍 your issue might get ignored & closed if you don't try this)
Additional information
The text was updated successfully, but these errors were encountered: