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

Exception when returning from parent page #4

Closed
be-swarm opened this issue Sep 30, 2023 · 4 comments
Closed

Exception when returning from parent page #4

be-swarm opened this issue Sep 30, 2023 · 4 comments

Comments

@be-swarm
Copy link

If the control is placed in a secondary page, when you return to the main page an exception is thrown.

Step to reproduce:
Create a page with your control.
register it in di (optional)
builder.Services.AddSingleton();

From main page:
await Shell.Current.GoToAsync($"{nameof(YourPage}");

From your page
await Shell.Current.GoToAsync($"..");

Exception:
System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'AndroidX.Camera.View.PreviewView'.'

@afriscic
Copy link
Owner

Try to add it in DI as transient and/or override OnDisappearing and set CameraEnabled to false to close the camre before you move out of the page.

@tolgraven
Copy link

tolgraven commented Nov 24, 2023

This should be fixed by the PR my colleague got merged (thanks for the quick turnaround @afriscic), so try the latest nuget @be-swarm

Edit: and feel free to close the issue

@geertgeerits
Copy link

Same problem here.
From main page to secondary page: await Navigation.PushAsync(new PageScanNT());
Using the back button of the page to return, than I get also that error: Cannot access a disposed object.
I did set CameraEnabled to false in the OnDisappering event but still that error.
BarcodeScanning.Native.Maui version 1.0.2
Visual Studio 2022 version 17.8.1

@afriscic
Copy link
Owner

OK, I have finally managed to consistently replicate this error from your scenario and found the culprit.
Should be fixed in 1.0.3 and I'll mark this issue as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants