mtellect / CameraDeepAR

MIT License
32 stars 50 forks source link

camera crash in ios #40

Open YaraEslam opened 2 years ago

YaraEslam commented 2 years ago

when opening the camera for the first time it works fine but then it crashes and opens a white screen, Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit"

mohdtaha60 commented 2 years ago

Any solution? Facing the same issue

mtellect commented 2 years ago

Show me camera class

Hi99simon commented 2 years ago

"target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit"

YaraEslam commented 2 years ago

@mtellect
This is my camera class work fine for android and first time in ios then open white screen

class AddStream extends StatefulWidget { AddStream(); @override _AddStreamState createState() => _AddStreamState(); }

class _AddStreamState extends State {

CameraDeepArController cameraDeepArController ;

bool isRecording = false; bool recorded = false; CameraDirection cameraDirection = CameraDirection.back; AudioCache cache = new AudioCache(); AudioPlayer player = new AudioPlayer();

String videoPath; final GlobalKey _LoaderDialog = new GlobalKey(); bool btnAppear = false;

int currentPageMask = 0; int currentPageFilter = 0; int currentPageEffect = 0; int currentPageSound = 0; String choose = "";

@override void dispose() { super.dispose(); player.pause(); player.stop(); }

@override void initState() { super.initState(); }

@override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Container( child: Stack( children: [ (videoPath==null)?CameraDeepAr( cameraMode: CameraMode.masks, cameraDirection: cameraDirection, recordingMode: RecordingMode.video, onCameraReady: (isReady) { print("hh $isReady"); }, onImageCaptured: (path) {}, onVideoRecorded: (path) { try { isRecording = false; Progress.showLoadingDialog(context, _LoaderDialog); Timer.run(() { setState(() { recorded = true; btnAppear = false; videoPath = path; }); }); player.stop(); Navigator.of(context, rootNavigator: true).pop(); }catch(e){ print("iiiiii $e"); } }, supportedEffects: Effects.values, supportedFilters: Filters.values, supportedMasks: Masks.values, androidLicenceKey: CameraDeep.androidApiKey, iosLicenceKey: CameraDeep.iosApiKey, cameraDeepArCallback: (c) async { cameraDeepArController = c; }, ) : Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: BetterPlayer.file( videoPath, betterPlayerConfiguration: BetterPlayerConfiguration( fit: BoxFit.fill, looping: false, autoPlay: false, aspectRatio: 16 / MediaQuery.of(context).size.width, ), )),

            (videoPath == null)?Positioned(
                left: 27,
                bottom: MediaQuery.of(context).size.height *.35,
                child: Container(
                  width: 55,
                  //height: 322,
                  padding: EdgeInsets.fromLTRB(12,20,12,20),
                  decoration: BoxDecoration(
                      color: blackLight2,
                      borderRadius: BorderRadius.circular(29)
                  ),
                  child: Column(
                    children: [
                      InkWell(
                          child: svgImage("iconMask", 30),
                          onTap: (){
                            Timer.run(() {
                              setState(() {
                                choose = "masks";
                              });
                            });
                          }),
                      SizedBox(height: 14,),
                      InkWell(
                          child: svgImage("iconFilter", 30),
                          onTap: (){
                            Timer.run(() {
                              setState(() {
                                choose = "filters";
                              });
                            });
                          }),
                      SizedBox(height: 14,),
                      InkWell(
                          child: svgImage("iconEffect", 30),
                          onTap: (){
                            Timer.run(() {
                              setState(() {
                                choose = "effects";
                              });
                            });
                          }),
                    ],
                  ),
                )):SizedBox.shrink(),

            (videoPath!=null)?Positioned(
                bottom: 50,
                left: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    InkWell(
                      child: Container(
                          width: 125,
                          // height: 45,
                          padding: EdgeInsets.all(8),
                          decoration: BoxDecoration(
                              color: blackLight2,
                              borderRadius: BorderRadius.circular(29)
                          ),
                          child: Center(
                            child: Text("Discard", style: textStyle.copyWith(
                                fontWeight: FontWeight.bold),),
                          )
                      ),
                      onTap: (){
                        Timer.run(() {
                          setState(() {
                            videoPath = null;
                            recorded = false;
                            isRecording = false;
                          });
                        });
                      },
                    ),
                  ],
                )):SizedBox.shrink(),
            (videoPath!=null)?Positioned(
                bottom: 50,
                right: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    InkWell(
                        child: Container(
                            width: 125,
                            padding: EdgeInsets.all(8),
                            decoration: BoxDecoration(
                                color: blackLight2,
                                borderRadius: BorderRadius.circular(29)
                            ),
                            child: Text("Upload", style: textStyle.copyWith(
                                fontWeight: FontWeight.bold, fontSize: 14), textAlign: TextAlign.center,)
                        ),
                        onTap: addVideo
                    )
                  ],
                )):SizedBox.shrink(),

            (videoPath==null)?Positioned(
                bottom: 15,
                left: 15,
                right: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [

                    SizedBox(width: 14,),
                    InkWell(
                      child: SvgPicture.asset(
                        (btnAppear)?"assets/images/stopIcon.svg":"assets/images/playIcon.svg",
                        //semanticsLabel: 'Acme Logo',
                        height: 84,
                        width: 64,
                      ),
                      //Image.asset("assets/images/playBtn.png", height: 84, width: 64,),
                      onTap: (){
                        if (null == cameraDeepArController) return;
                        if(!isRecording){
                          cameraDeepArController.startVideoRecording();
                          isRecording = true;
                          Timer.run(() {
                            setState(() {
                              btnAppear = true;
                            });
                          });

                        }else{
                          cameraDeepArController.stopVideoRecording();
                          isRecording = false;
                          Timer.run(() {
                            setState(() {
                              btnAppear = false;
                            });
                          });
                        }
                      },
                    ),
                    //Icon(Icons.play_arrow, size: 60, color: white,),
                    SizedBox(width: 14,),

                  ],
                )):SizedBox.shrink(),
            (videoPath==null)?Positioned(
                bottom: 25,
                right: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [

                    SizedBox(width: 14,),
                    InkWell(
                      //backgroundColor: Colors.white10,
                        child: Container(
                          padding: EdgeInsets.all(4.0),
                          child: Image.asset(
                            'assets/images/ic_switch_camera_3.png',
                            color: white,//grey[200],
                            width: 42.0,
                            height: 42.0,
                          ),
                        ),
                        onTap: () {
                          if(cameraDirection == CameraDirection.front){
                            cameraDeepArController.switchCameraDirection(direction: CameraDirection.back);
                            Timer.run(() {
                              setState(() {
                                cameraDirection = CameraDirection.back;
                              });
                            });

                          }else{
                            cameraDeepArController.switchCameraDirection(direction: CameraDirection.front);
                            Timer.run(() {
                              setState(() {
                                cameraDirection = CameraDirection.front;
                              });
                            });

                          }
                        }),
                    //Icon(Icons.play_arrow, size: 60, color: white,),
                    SizedBox(width: 14,),

                  ],
                )):SizedBox.shrink(),
            (choose == "" || choose.isEmpty)?SizedBox.shrink():
            Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                height: 180,
                decoration: BoxDecoration(
                    color: white,
                    borderRadius: BorderRadius.only(topLeft: Radius.circular(16),
                      topRight: Radius.circular(16), )
                ),
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: IconButton(
                              onPressed: () {
                                Timer.run(() {
                                  setState(() {
                                    choose = "";
                                  });
                                });

                              },
                              icon: Icon(
                                Icons.clear,
                                size: 30,
                                color: Colors.black,
                              )),
                        ),
                      ],
                    ),
                    SingleChildScrollView(
                      padding: EdgeInsets.all(6),
                      scrollDirection: Axis.horizontal,
                      child: Row(
                        children: List.generate(
                            (choose == "effects")?Effects.values.length : (choose == "masks")? Masks.values.length:
                            Filters.values.length,
                                (p) {
                              bool active = (choose == "effects")? currentPageEffect == p :
                              (choose == "masks")? currentPageMask == p: (choose == "filters")? currentPageFilter == p:
                              currentPageSound == p;
                              return GestureDetector(
                                onTap: () {
                                  (choose == "effects")? currentPageEffect = p :
                                  (choose == "masks")? currentPageMask = p:  (choose== "filters")?currentPageFilter = p:
                                  currentPageSound = p;

                                  setState(() {
                                    active = (choose == "effects")? currentPageEffect == p :
                                    (choose == "masks")? currentPageMask == p: (choose == "filters")? currentPageFilter == p:
                                    currentPageSound == p;
                                  });
                                  if(choose == "effects")cameraDeepArController.changeEffect(p) ;
                                  else if (choose == "masks") cameraDeepArController.changeMask(p);
                                  else if (choose == "filters")cameraDeepArController.changeFilter(p);
                                  else {

                                  }
                                  },
                                child: Container(
                                    margin: EdgeInsets.all(5),
                                    padding: EdgeInsets.all(8),
                                    width: active ? 80 : 60,
                                    height: active ? 80 : 60,
                                    alignment: Alignment.center,
                                    decoration: BoxDecoration(
                                        color:
                                        active ? primary : Colors.grey[400],
                                        shape: BoxShape.circle),
                                    child: Text(
                                      (choose == "effects")?"${Effects.values.elementAt(p).toString().substring(8)}"
                                          :(choose == "filters")?"${Filters.values.elementAt(p).toString().substring(8)}"
                                          :"${Masks.values.elementAt(p).toString().substring(6)}",
                                      textAlign: TextAlign.center,
                                      style: textStyle.copyWith(
                                          fontSize: active ? 14 : 12,
                                          color: white),
                                    )),
                              );
                            }),
                      ),
                    ),
                  ],
                ),
              ),
            )
          ],
        ),
      )
  ),
);

}

addVideo() async {

if (videoPath != null || recorded) {

  alertDialog(context, videoPath);
}
else {
  alertDialog(context, "Please, choose video to upload!!");
}

} }

mtellect commented 2 years ago

Please use the example on the Dev branch.

YaraEslam commented 2 years ago

@mtellect i use it and add some widgets to it only

mtellect commented 2 years ago

@mtellect This is my camera class work fine for android and first time in ios then open white screen

class AddStream extends StatefulWidget { AddStream(); @OverRide _AddStreamState createState() => _AddStreamState(); }

class _AddStreamState extends State {

CameraDeepArController cameraDeepArController ;

bool isRecording = false; bool recorded = false; CameraDirection cameraDirection = CameraDirection.back; AudioCache cache = new AudioCache(); AudioPlayer player = new AudioPlayer();

String videoPath; final GlobalKey _LoaderDialog = new GlobalKey(); bool btnAppear = false;

int currentPageMask = 0; int currentPageFilter = 0; int currentPageEffect = 0; int currentPageSound = 0; String choose = "";

@OverRide void dispose() { super.dispose(); player.pause(); player.stop(); }

@OverRide void initState() { super.initState(); }

@OverRide Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Container( child: Stack( children: [ (videoPath==null)?CameraDeepAr( cameraMode: CameraMode.masks, cameraDirection: cameraDirection, recordingMode: RecordingMode.video, onCameraReady: (isReady) { print("hh $isReady"); }, onImageCaptured: (path) {}, onVideoRecorded: (path) { try { isRecording = false; Progress.showLoadingDialog(context, _LoaderDialog); Timer.run(() { setState(() { recorded = true; btnAppear = false; videoPath = path; }); }); player.stop(); Navigator.of(context, rootNavigator: true).pop(); }catch(e){ print("iiiiii $e"); } }, supportedEffects: Effects.values, supportedFilters: Filters.values, supportedMasks: Masks.values, androidLicenceKey: CameraDeep.androidApiKey, iosLicenceKey: CameraDeep.iosApiKey, cameraDeepArCallback: (c) async { cameraDeepArController = c; }, ) : Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: BetterPlayer.file( videoPath, betterPlayerConfiguration: BetterPlayerConfiguration( fit: BoxFit.fill, looping: false, autoPlay: false, aspectRatio: 16 / MediaQuery.of(context).size.width, ), )),

            (videoPath == null)?Positioned(
                left: 27,
                bottom: MediaQuery.of(context).size.height *.35,
                child: Container(
                  width: 55,
                  //height: 322,
                  padding: EdgeInsets.fromLTRB(12,20,12,20),
                  decoration: BoxDecoration(
                      color: blackLight2,
                      borderRadius: BorderRadius.circular(29)
                  ),
                  child: Column(
                    children: [
                      InkWell(
                          child: svgImage("iconMask", 30),
                          onTap: (){
                            Timer.run(() {
                              setState(() {
                                choose = "masks";
                              });
                            });
                          }),
                      SizedBox(height: 14,),
                      InkWell(
                          child: svgImage("iconFilter", 30),
                          onTap: (){
                            Timer.run(() {
                              setState(() {
                                choose = "filters";
                              });
                            });
                          }),
                      SizedBox(height: 14,),
                      InkWell(
                          child: svgImage("iconEffect", 30),
                          onTap: (){
                            Timer.run(() {
                              setState(() {
                                choose = "effects";
                              });
                            });
                          }),
                    ],
                  ),
                )):SizedBox.shrink(),

            (videoPath!=null)?Positioned(
                bottom: 50,
                left: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    InkWell(
                      child: Container(
                          width: 125,
                          // height: 45,
                          padding: EdgeInsets.all(8),
                          decoration: BoxDecoration(
                              color: blackLight2,
                              borderRadius: BorderRadius.circular(29)
                          ),
                          child: Center(
                            child: Text("Discard", style: textStyle.copyWith(
                                fontWeight: FontWeight.bold),),
                          )
                      ),
                      onTap: (){
                        Timer.run(() {
                          setState(() {
                            videoPath = null;
                            recorded = false;
                            isRecording = false;
                          });
                        });
                      },
                    ),
                  ],
                )):SizedBox.shrink(),
            (videoPath!=null)?Positioned(
                bottom: 50,
                right: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    InkWell(
                        child: Container(
                            width: 125,
                            padding: EdgeInsets.all(8),
                            decoration: BoxDecoration(
                                color: blackLight2,
                                borderRadius: BorderRadius.circular(29)
                            ),
                            child: Text("Upload", style: textStyle.copyWith(
                                fontWeight: FontWeight.bold, fontSize: 14), textAlign: TextAlign.center,)
                        ),
                        onTap: addVideo
                    )
                  ],
                )):SizedBox.shrink(),

            (videoPath==null)?Positioned(
                bottom: 15,
                left: 15,
                right: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [

                    SizedBox(width: 14,),
                    InkWell(
                      child: SvgPicture.asset(
                        (btnAppear)?"assets/images/stopIcon.svg":"assets/images/playIcon.svg",
                        //semanticsLabel: 'Acme Logo',
                        height: 84,
                        width: 64,
                      ),
                      //Image.asset("assets/images/playBtn.png", height: 84, width: 64,),
                      onTap: (){
                        if (null == cameraDeepArController) return;
                        if(!isRecording){
                          cameraDeepArController.startVideoRecording();
                          isRecording = true;
                          Timer.run(() {
                            setState(() {
                              btnAppear = true;
                            });
                          });

                        }else{
                          cameraDeepArController.stopVideoRecording();
                          isRecording = false;
                          Timer.run(() {
                            setState(() {
                              btnAppear = false;
                            });
                          });
                        }
                      },
                    ),
                    //Icon(Icons.play_arrow, size: 60, color: white,),
                    SizedBox(width: 14,),

                  ],
                )):SizedBox.shrink(),
            (videoPath==null)?Positioned(
                bottom: 25,
                right: 15,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [

                    SizedBox(width: 14,),
                    InkWell(
                      //backgroundColor: Colors.white10,
                        child: Container(
                          padding: EdgeInsets.all(4.0),
                          child: Image.asset(
                            'assets/images/ic_switch_camera_3.png',
                            color: white,//grey[200],
                            width: 42.0,
                            height: 42.0,
                          ),
                        ),
                        onTap: () {
                          if(cameraDirection == CameraDirection.front){
                            cameraDeepArController.switchCameraDirection(direction: CameraDirection.back);
                            Timer.run(() {
                              setState(() {
                                cameraDirection = CameraDirection.back;
                              });
                            });

                          }else{
                            cameraDeepArController.switchCameraDirection(direction: CameraDirection.front);
                            Timer.run(() {
                              setState(() {
                                cameraDirection = CameraDirection.front;
                              });
                            });

                          }
                        }),
                    //Icon(Icons.play_arrow, size: 60, color: white,),
                    SizedBox(width: 14,),

                  ],
                )):SizedBox.shrink(),
            (choose == "" || choose.isEmpty)?SizedBox.shrink():
            Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                height: 180,
                decoration: BoxDecoration(
                    color: white,
                    borderRadius: BorderRadius.only(topLeft: Radius.circular(16),
                      topRight: Radius.circular(16), )
                ),
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: IconButton(
                              onPressed: () {
                                Timer.run(() {
                                  setState(() {
                                    choose = "";
                                  });
                                });

                              },
                              icon: Icon(
                                Icons.clear,
                                size: 30,
                                color: Colors.black,
                              )),
                        ),
                      ],
                    ),
                    SingleChildScrollView(
                      padding: EdgeInsets.all(6),
                      scrollDirection: Axis.horizontal,
                      child: Row(
                        children: List.generate(
                            (choose == "effects")?Effects.values.length : (choose == "masks")? Masks.values.length:
                            Filters.values.length,
                                (p) {
                              bool active = (choose == "effects")? currentPageEffect == p :
                              (choose == "masks")? currentPageMask == p: (choose == "filters")? currentPageFilter == p:
                              currentPageSound == p;
                              return GestureDetector(
                                onTap: () {
                                  (choose == "effects")? currentPageEffect = p :
                                  (choose == "masks")? currentPageMask = p:  (choose== "filters")?currentPageFilter = p:
                                  currentPageSound = p;

                                  setState(() {
                                    active = (choose == "effects")? currentPageEffect == p :
                                    (choose == "masks")? currentPageMask == p: (choose == "filters")? currentPageFilter == p:
                                    currentPageSound == p;
                                  });
                                  if(choose == "effects")cameraDeepArController.changeEffect(p) ;
                                  else if (choose == "masks") cameraDeepArController.changeMask(p);
                                  else if (choose == "filters")cameraDeepArController.changeFilter(p);
                                  else {

                                  }
                                  },
                                child: Container(
                                    margin: EdgeInsets.all(5),
                                    padding: EdgeInsets.all(8),
                                    width: active ? 80 : 60,
                                    height: active ? 80 : 60,
                                    alignment: Alignment.center,
                                    decoration: BoxDecoration(
                                        color:
                                        active ? primary : Colors.grey[400],
                                        shape: BoxShape.circle),
                                    child: Text(
                                      (choose == "effects")?"${Effects.values.elementAt(p).toString().substring(8)}"
                                          :(choose == "filters")?"${Filters.values.elementAt(p).toString().substring(8)}"
                                          :"${Masks.values.elementAt(p).toString().substring(6)}",
                                      textAlign: TextAlign.center,
                                      style: textStyle.copyWith(
                                          fontSize: active ? 14 : 12,
                                          color: white),
                                    )),
                              );
                            }),
                      ),
                    ),
                  ],
                ),
              ),
            )
          ],
        ),
      )
  ),
);

}

addVideo() async {

if (videoPath != null || recorded) {

  alertDialog(context, videoPath);
}
else {
  alertDialog(context, "Please, choose video to upload!!");
}

} }

This is not the example on the Dev branch sir. Take a look yourself:

https://github.com/mtellect/CameraDeepAR/tree/dev/example/lib

YaraEslam commented 2 years ago

@mtellect

I tried it and have the same error

mtellect commented 2 years ago

Show me a screenshot

YaraEslam commented 2 years ago

@mtellect WhatsApp Image 2022-02-02 at 5 06 29 PM

mtellect commented 2 years ago

A screenshot of this class

YaraEslam commented 2 years ago

Screenshot (41) Screenshot (42) Screenshot (43) Screenshot (44) Screenshot (45) Screenshot (46) @mtellect

mtellect commented 2 years ago

Now what's the error??

send a screenshot of your info.plist

YaraEslam commented 2 years ago

Screenshot (47) Screenshot (48) Screenshot (49) Screenshot (51) @mtellect the error is showing white screen when open the camera again

mtellect commented 2 years ago

your DeepAr Config screenshot

YaraEslam commented 2 years ago

Screenshot (52) Screenshot (53) @mtellect

mtellect commented 2 years ago

i'd confirm and let you know

YaraEslam commented 2 years ago

any update, please @mtellect

rlee1990 commented 2 years ago

@mtellect I too am having this issue.

rlee1990 commented 2 years ago

@YaraEslam Are you calling _cameraDeepArController.dispose(); Calling that has kept me from getting the white screen and has the plugin still working on iOS. I still have this: Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}> But it still all works.

YaraEslam commented 2 years ago

@rlee1990
Tried it but still showing white screen

rlee1990 commented 2 years ago

Try using my fork with the dispose method and let me know