Closed badbeoti closed 1 year ago
@badbeoti Thanks for sharing the code snippet. We will let you know if this issue is fixed.
As you can see occur severe hang when call getTimeOfDay.
This timing is same that await this.reader.startScanning()
.
And I have some question.
Currently experiencing inconvenience due to bugs. Anyway, I want you guys to solve it quickly.
@Dynamsoft-Henry
@Dynamsoft-Henry Can you check please.
Working on it now
Hi @badbeoti
For the 3 questions:
Question:
Answer:
What do you mean by "every single time" actually? You can addResultListener
before the first-time barcode scanning. You don't need to always addResultListener
or removeAllResultListeners
during the video previewing. If you want to stop scanning the barcodes but not going to close the camera, please use the method stopScanning
. When you have to trigger removeAllResultListeners
is the time you want to leave the camera view page and close the camera.
Question:
Answer:
"So many threads" is not a problem. At least, we also have that many threads when running our sample. This is not the reason for the hang.
Based on the code snippet, there are some suggestions from our developer.
We suggest you to make some modifications on the "useEffect":
useEffect(() => { if (reader) { // @ts-ignore console.log(router.params.key, 'Scan'); console.log(reader, 'Scan'); (async () => { try { loaderStore.setLoading(true); console.log(router.params.key, 'reader.startScanning start'); await reader.startScanning(); console.log(router.params.key, 'reader.startScanning end'); loaderStore.setLoading(false); // move you code of addResultListener from takeScreenShotAndBarcode to this place. reader.addResultListener(async (data) => { if (data) { const regularize = regularizeResults(data); if (regularize.length > 0) { // remove the removeAllResultListener here. // reader.removeAllResultListeners(); if (router.params.withImage) { // remove the clear() here // await clear(); // NOTE: react-native-view-shot // 해당 라이브러리는 ios 환경을 캡쳐할 수 없는 이슈 if (Platform.OS === 'ios') { goPrevRoute(regularize[0].trim(), false); } else { goPrevRoute(regularize[0].trim(), true, url); } } else { await reader.stopScanning(); // remove the clear() here //await clear(); goPrevRoute(regularize[0].trim(), false); } } } }); } catch (e) { console.log(e); } })(); // } else { (async () => { loaderStore.setLoading(true); await createReader(); loaderStore.setLoading(false); })(); } // Add the following code return () => { await clear(); } }, []);//Leave the second parameter of useEffect empty
We can't run your code snippet because it seems to be not completed and includes some third-party components. We are not sure whether the above suggestions can solve your issue.
The following question we can't understand. Are there any relations between getTimeOfDay and our startScanning?
As you can see occur severe hang when call getTimeOfDay. This timing is same that await this.reader.startScanning().
First, We fixed the problem by modifying the DYSCameraView.m Can you check this code got no problem?
And "What it's mean every single time". You need to know multiple scan page we have.
We use many Scan
page each has unique key value(and it is new created every single time).
So, User can visit different Scan
page. and it can happen in a very short time.
Test attempted without addResultListener
and removeAllResultListeners
.
It had only left DCVCameraView
.
const Scan = observer(() => {
return (
<Layout collapsable={false}>
<DCVCameraView
style={{flex: 1, justifyContent: 'space-between'}}
ref={DCVRef}
overlayVisible={true}
// @ts-ignore
torchButton={{visible: true}}
torchState={EnumTorchState.OFF}
scanRegionVisible={true}
scanRegion={ScanRegion}
>
</DCVCameraView>
</Layout>
);
});
export default Scan;
And we got same result(severe hang).
We also tried a different code. Similar to what you suggested like clearFn inside useEffect()
But we got same result again.
We checked the error log more accurately using Sentry.
We can found __psynch_mutexwait
when we got severe hang.
I think it's not problem in react-native
cause it happen only iOS.
I'm not iOS developer. I don't know exactly but you guys something seems to have set the mutex wrong.
If not maybe we used this wrong.
if ([StaticClass instance].dce == nil) {
[StaticClass instance].dce = [[DynamsoftCameraEnhancer alloc] init];
}
Anyway we solve problem use this.
[StaticClass instance].dce = [[DynamsoftCameraEnhancer alloc] init]
only one time.
If this way is wrong choice. Please leave a comment. Thx.
@Dynamsoft-Henry
@badbeoti
Your change is correct.
@Dynamsoft-Henry Any release plan for this fix?
@badbeoti If possible, can you please create a PR for this fix?
Hi @tousif-p99soft
Actually which version are you working on? Our latest version is v1.1.12. Would you like to try the latest version? Our developers said they have fixed this issue in the v1.1.12 version.
"dynamsoft-capture-vision-react-native": "^1.1.12",
Hi,
I am using the same version but that code change is not there
On Thu, 7 Sept 2023 at 11:23, Dynamsoft-Henry @.***> wrote:
Hi @tousif-p99soft https://github.com/tousif-p99soft
Actually which version are you working on? Our latest version is v1.1.12. Would you like to try the latest version? Our developers said they have fixed this issue in the v1.1.12 version.
"dynamsoft-capture-vision-react-native": "^1.1.12",
— Reply to this email directly, view it on GitHub https://github.com/Dynamsoft/capture-vision-react-native/issues/41#issuecomment-1709518171, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4TTLCIKYRCO3ARANU3475TXZFOL5ANCNFSM6AAAAAAZISW3OM . You are receiving this because you were mentioned.Message ID: @.***>
@tousif-p99soft Thanks, we will check it again.
@tousif-p99soft Would you like to send us your simplified project or code snippet to show us how you are using the SDK.
Since we can't reproduce the frozen. We need your code snippet to make more tests so that we can confirm the bugs are fixed before release.
@tousif-p99soft If possible, would you like to share your package.json file with us?
It only happens on iOS(I use RN: iOS-13.0, device: 16.4)
Using package version "dynamsoft-capture-vision-react-native": "^1.1.7", "react": "18.2.0", "react-native": "0.71.7",
Unfortunately, this is not my code, so I don't know the reason for writing etc. in detail. So if there is a problem, I think it needs to be fixed. I would like to know the cause of Severe Hang additionally. Is there a logic that intentionally triggers Hang?