Code Monkey home page Code Monkey logo

Comments (15)

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024 1

@badbeoti
Thanks for sharing the code snippet. We will let you know if this issue is fixed.

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024 1

@badbeoti

Your change is correct.

from capture-vision-react-native-samples.

badbeoti avatar badbeoti commented on July 19, 2024

스크린샷 2023-06-21 오후 2 15 58
스크린샷 2023-06-21 오후 2 16 16


As you can see occur severe hang when call getTimeOfDay.
This timing is same that await this.reader.startScanning().

And I have some question.

  1. Should i create instance and addResultListener every single time to scan barcode?
  2. If the above is correct, Should i stopScanning and removeAllResultListeners after scan barcode every time?
  3. I tried to Profiling from xCode. And i found so many thread for using DynamsoftBarcode or DynamsoftCamera. Is it right? Please tell me if I'm using it wrong.

Currently experiencing inconvenience due to bugs.
Anyway, I want you guys to solve it quickly.

@Dynamsoft-Henry

from capture-vision-react-native-samples.

badbeoti avatar badbeoti commented on July 19, 2024

@Dynamsoft-Henry
Can you check please.

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024

Working on it now

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024

Hi @badbeoti

For the 3 questions:

Question:

  1. Should i create instance and addResultListener every single time to scan barcode?
  2. If the above is correct, Should i stopScanning and removeAllResultListeners after scan barcode every time?

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:

  1. I tried to Profiling from xCode. And i found so many thread for using DynamsoftBarcode or DynamsoftCamera. Is it right? Please tell me if I'm using it wrong.

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.

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024

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().

from capture-vision-react-native-samples.

badbeoti avatar badbeoti commented on July 19, 2024

image

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.

image

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

from capture-vision-react-native-samples.

tousif-p99soft avatar tousif-p99soft commented on July 19, 2024

@Dynamsoft-Henry
Any release plan for this fix?

from capture-vision-react-native-samples.

tousif-p99soft avatar tousif-p99soft commented on July 19, 2024

@badbeoti
If possible, can you please create a PR for this fix?

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024

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",

from capture-vision-react-native-samples.

tousif-p99soft avatar tousif-p99soft commented on July 19, 2024

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024

@tousif-p99soft
Thanks, we will check it again.

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024

@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.

from capture-vision-react-native-samples.

Dynamsoft-Henry avatar Dynamsoft-Henry commented on July 19, 2024

@tousif-p99soft
If possible, would you like to share your package.json file with us?

from capture-vision-react-native-samples.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.