Does the unity package dispose the camera when navigate pop?
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:
- Go to 'CameraPage'
- Click on 'ElevatedButton'
- Navigate to 'UnityPage '
- Navigate pop to CameraPage
- 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
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.
I know what's the error eventually.
Try this solution: https://github.com/Ahmadre/unity_widget#solutions-to-problems