Giter Site home page Giter Site logo

When trying to open CameraAsync: System.NullReferenceException: 'Object reference not set to an instance of an object.' about camera.maui HOT 7 OPEN

GabrieleViga avatar GabrieleViga commented on September 16, 2024 1
When trying to open CameraAsync: System.NullReferenceException: 'Object reference not set to an instance of an object.'

from camera.maui.

Comments (7)

hjam40 avatar hjam40 commented on September 16, 2024

Hi

In witch platform?

from camera.maui.

UkeHa avatar UkeHa commented on September 16, 2024

@hjam40, happens for me once i try to go back to the previous page on iOS

if (await cameraView.StopCameraAsync() == CameraResult.Success)
		{
			try
			{
				await Shell.Current.GoToAsync("..", new Dictionary<string, object>()
				{
					{"Barcode",barcode }
				});

			}
			catch (Exception exception)
			{
				Console.WriteLine(exception);
				throw;
			}

from camera.maui.

migueBarrera avatar migueBarrera commented on September 16, 2024

I have the same issue in production. On Android 11 and 12.
It doesn't happen all the time, just sometimes.

I use this code:

image

image

@hjam40 any idea please?

from camera.maui.

archblaze avatar archblaze commented on September 16, 2024

I'm using the same stock code as @migueBarrera and see the error pretty consistently when I'm flipping between Flashmodes from Enabled to Disabled. To make the camera recognize the change in modes (since the camera is already started), I force a StopCameraAsync() then a StartCameraAsync() (like above) immediately before I make the call to TakePhotoAsync(). I think it becomes a race condition as the TakePhotoAsync() is the call throwing the exception. Even if I force the routines to block so each is performed in sequence, I tend to see it. Subsequent calls to TakePhotoAsync() don't fail unless I run it through the Stop/Start/Take sequence described above again.

from camera.maui.

migueBarrera avatar migueBarrera commented on September 16, 2024

@hjam40 any idea about this error??

from camera.maui.

archblaze avatar archblaze commented on September 16, 2024

@hjam40 any idea about this error??

Actually, I'm no longer getting the error because I rewrote the code to tightly control when a StartCameraAsync() and when a StopCameraAsync() is called. I no longer force a stop and start after changing Flashmodes, but I do still perform the stop and start after changing cameras (front to back, etc.) Additionally, I'm only deploying onto Android 13 or greater now...that's helped a lot. Thanks for following up!

from camera.maui.

vovanb avatar vovanb commented on September 16, 2024

same problem on Android - after call to await cameraViewMy.StopCameraAsync(); and then (await cameraViewMy.StartCameraAsync() give exception cameraViewMy.TakePhotoAsync(ImageFormat.JPEG)

from camera.maui.

Related Issues (20)

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.