-
Notifications
You must be signed in to change notification settings - Fork 1
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
iOS Crashes #6
Comments
Hi @bobekos, sorry you're running into issues! Might I ask what you are logging for |
Nothing. It seems that
Kind of. The setup and the logic is managed by a cubit from the bloc package. The dispose function is called when the cubit is closed. The cubit is closed when the "scanner" widget is removed from the widget tree.
Also here the deviceCapture is null to this time, because the "deviceArrival" event never happens. It seems like create a new instance of the capture instance is cause the error. |
So the fact that there is no handle makes sense why there is an issue regarding a valid handle.
Do you mean that even when you first start the app/connect the scanner it doesn't get called? Or is this only after you've first removed the scanner and then try to reconnect? Also what kind of device(s) are you connecting to? |
When the user calls up a configured scanner for the first time (we use the SocketMobile D-740 models), we get the following values back: Then when the user leaves and enter the "scanner" widget again and the _mainCapture instance is initialized again the crash occurs (it doesn't happen all the time). The same code is working on android. Edit: |
This is the correct behavior. I can cover this more when I explain what a handle is.
These responses are success responses. Whenever you get a 0 it means there was no errors/any other issues. So in the above instance, the
You might be running into an issue with re-initializing the main capture instance because it’s actually not supposed to be reinitialized. In order to reinitialize the main capture instance, you need to perform a close of the main capture instance. This could be creating a conflict because you are, in essence, trying to open a main capture instance on top of a main capture instance. If you really want to close your main capture instance (instead of just closing/removing device without closing the main thread), maybe in your Again, from what you are describing it doesn’t seem like you need to close the main instance, but just If you look at the capture flutter sample, you’ll see in
Great question! The concept of a handle is a relatively common programming term (especially with more event-driven ecosystems such as ours) used to represent a reference or identifier to an object or resource in a system. So in our SDK we use a handle to identify a specific connection/session instance. These instances can represent a connection to a physical device (barcode scanner) or the main instance. This is a connection is a tether from your device/app to our SDK which will act as a conduit for communication (i.e. allowing you to then connect to other devices and detect event changes). So the handle itself is different every time there is a connection/reconnection. Upon every instantiation a latest handle is generated. This ensures that the handle used in the connection is the most up to date (not cached or recycled) and allows for more efficient authentication. Think of it like a session token!
At the moment we are doing it this way because you can get a few different response types from That being said, we are always looking to improve typing in our SDK and moving forward we can work on more precisely typing the responses from this event listener. There are other features/updates we are working on at this time that take priority but it is definitely in the pipeline in the future. Your feedback here is very much appreciated!
Apologies for not having more specific documentation regarding these errors. We are working on improving the documentation but there have been documentation updates that have recently taken priority (Socket Cam, NFC updates, etc.). We didn't realize this type of documentation was important for our user base so we greatly appreciate the feedback here from you as well! We can also try to prioritize this in the future. Again, thank you for bringing it to our attention. What you can do nowAs I recommended earlier, changing the structure of your event handling so as to not close the main instance necessarily (unless you want to directly want close it, in which case you will need to call the close on Another course of action would be to ensure you are using a newer version of the flutter SDK. We just released a newer version recently that also offers support for SocketCam C820! Also, feel free to refer to our capture sdk sample. It can demonstrate how/when to open/close the main instance and how to handle the events, errors, and widget state! |
First of all, thank you for the very detailed answer. Here are a few more thoughts I would like to share with you.
Then why is this (session) identifier even passed down to the API level? This makes the interface more confusing and offers absolutely no advantages as far as I can see. At no point where the API is used does I need the handle value (even in the example, the values are only logged as far as I could see). Since this value is unknown to me, I cannot deduce anything from it. Unless you can somehow use it for debugging purpose.
Here I would simply break up this abstraction by giving the API (_openClient(onEvent, onError, etc)) different callbacks. The advantage would be that I can see immediately which types I can expect and what exactly this function does. I would be type safety and I wouldn't have to do any type casting. OnCaptureEvent(CaptureEvent event)? Alright i know what to do and how handle them. OnErrorEvent(CaptureError error)? Oh something went wrong, let me check it.
The problem is that I cannot guarantee that the user is using a SocketMobile scanner. That's why our app offers different implementations for different scanners. The resources for the respective connection should of course only be initialized when I need them. Why open a mainCapture instance if the user in this app does not use a scanner at all? I will now try to close the session completely after the dispose. Unfortunately I don't understand why this has to be a runtime exception when i try to initialize the main instance again ? You could also catch it. And why this error does not occur on Android? Thank you again for your help. I'll take another look at the example and modify my implementation. |
We are currently using the 1.3.17 version of the sdk. Unfortunately we have some crashes on devices where the socket mobile companion app is not preinstalled (we can't guarantee that the user has installed your app). This happens only on iOS Devices. Android seems to work.
The scanning function is also not delivered globally to the app, but is only limited to a small part of the app. This is what our initialization setup looks like:
when the user is done with the scan function we dispose all the references (no catched errors here):
This works on devices where the socket mobile app is installed and also on first try when the device has no installed companion app. In this case we got this exception (which is fine):
But when we call the setup again, the app crashes with following content:
This also happens sometimes on devices where the companion app is installed, running and the scanner is connected.
The text was updated successfully, but these errors were encountered: