Start a new topic
Solved

Device Sensor Crash

Hi 


I'm getting this error:


#0 0x00000001002fd70c in wikitude::sdk_foundation::impl::DeviceMotionService::notifySensorEvent(wikitude::sdk_foundation::impl::SensorEvent const&) ()


I'm using an iPad Air 2 with iOS 10 and your Java Script SDK 6.1.0


I'm using the library to show POI, the error occurred when I open the AR for the 2nd time using Swift 3.


With an iPad Mini 2 the error occurs less frequent, I can open my AR View more than  20 times before getting the error, both iPad have the same version of the OS.


This is the code I execute when I'm leaving the AR view: 

deinit {
    //deinit start
    print("deinit ARViewController start")
    
    //Others
    print("deinit Others start")
    self.Map.delegate = nil
    self.poiManager = nil
    self.vTapGestureRecognizer?.delegate = nil
    self.vTapGestureRecognizer = nil
    print("deinit Others end")
    
    //SITUM
    print("deinit SITUM start")
    self.vSitumWrapper?.stopLocationUpdates()
    self.vSitumWrapper?.delegate = nil
    self.vSitumWrapper = nil
    print("deinit SITUM end")
    
    //WTarchitectView
    print("deinit WTarchitectView start")
    NotificationCenter.default.removeObserver(self)
    print("deinit WTarchitectView end")
    
    //LocationManager
    print("deinit LocationManager start")
    self.locationManager?.stopUpdatingLocation()
    self.locationManager?.stopUpdatingHeading()
    self.locationManager?.delegate = nil
    self.locationManager = nil
    print("deinit LocationManager end")
    
    //deinit end
    print("deinit ARViewController end")
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    
    if (self.isMovingFromParentViewController){
        self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
        self.architectView?.callJavaScript("AR.context.destroyAll()")
        self.architectView?.clearCache()
    }
}

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)
    if (self.isMovingFromParentViewController){
        self.stopArchitectViewRendering()
        self.architectView?.removeFromSuperview()
    }
}

func stopArchitectViewRendering(){
    if (self.architectView?.isRunning)!{
        self.architectView?.stop()
    }
}


The code you are looking is the one that gives me the best results, and I'm using Swift 3.


What do you recommend to change or doing.


Hello Marco,

Please note that we do not officially support Swift. As I want to make sure that this is not a Wikitude SDK issue, could you please test your app without using Swift and see if the issue occurs in this situation?

Thanks
Eva

 

The problem was with the  AR.context.destroyAll(); in that JS function, removing that line of code solved the problem.

loadPoisFromJsonData: function loadPoisFromJsonDataFn(poiData) {
    
    AR.context.destroyAll();
    
    World.markerList = [];
    
    for (var currentPlaceNr = 0; currentPlaceNr < poiData.length; currentPlaceNr++) {
        var singlePoi = {
            "id": poiData[currentPlaceNr].id,
            "latitude": parseFloat(poiData[currentPlaceNr].latitude),
            "longitude": parseFloat(poiData[currentPlaceNr].longitude),
            "altitude": parseFloat(poiData[currentPlaceNr].altitude),
            "title": poiData[currentPlaceNr].name,
            "description": poiData[currentPlaceNr].description
        };
        
        World.markerDrawable_idle = new AR.ImageResource(poiData[currentPlaceNr].PoiURL);
        World.markerDrawable_selected = new AR.ImageResource(poiData[currentPlaceNr].PoiURL);
        World.markerDrawable_directionIndicator = new AR.ImageResource(poiData[currentPlaceNr].PoiURL);
        
        World.markerList.push(new Marker(singlePoi));
    }
},

 

Hello Marco,

Thank you for updating your post and reporting your solution.

Eva

 

Login or Signup to post a comment