flutter-unity-view-widget icon indicating copy to clipboard operation
flutter-unity-view-widget copied to clipboard

Does the unity package dispose the camera when navigate pop?

Open Rainmaker44 opened this issue 4 years ago • 2 comments

Describe the bug Hello, Im using the Unity package to show AR content and the camera package (https://pub.dev/packages/camera) From the Camera page, i navigate to Unity page. When i pop to Camera page again, the camera is freezed and the app is not responding. Does the unity package dispose the camera when navigate pop?

To Reproduce Steps to reproduce the behavior:

  1. Go to 'CameraPage'
  2. Click on 'ElevatedButton'
  3. Navigate to 'UnityPage '
  4. Navigate pop to CameraPage
  5. Camera is freezed

Expected behavior The camera reinitialized and displays normally

Unity:

  • OS: [Android]
  • Version [-]

Smartphone:

  • Device: [Samsung Note 9]
  • OS: [Android 11]
  • Version [30]

Additional context

Code sample

CameraPage

ElevatedButton(
    onPressed: () async {
    await  Navigator.of(context).push(
        CupertinoPageRoute(
          builder: (context) => UnityPage(
            poi: _poi,
            excerpt: widget.excerpt,
            voyager: widget.voyager,
            onSoundStop: widget.onSoundStop,
          ),
        ),
      );                       
    //When i return from Unity Page, i re-initialize the camera
    await _controller.initialize();                       
    },

UnityPage while pop

BackButton(
    color: Colors.white,
       onPressed: () async {
           await _unityWidgetController.pause();
           Navigator.of(context).pop();
   },
),
Logs
D/AudioTrack( 4696): stop() called with 927552 frames delivered
I/Camera  ( 4696): close

Rainmaker44 avatar Oct 18 '21 09:10 Rainmaker44

I tried the camera package in an empty container view that would then navigate to unity ar and that was causing a lot of resizing issues with unity camera. So I'm guessing they are connected and a high possibility that the camera gets disposed.

AkhilRaja avatar Jan 30 '22 15:01 AkhilRaja

I know what's the error eventually.

Try this solution: https://github.com/Ahmadre/unity_widget#solutions-to-problems

Ahmadre avatar Apr 22 '22 14:04 Ahmadre