Select to view content in your preferred language

Unable to open database

2566
10
Jump to solution
11-04-2020 09:26 AM
MartinStamenkovski
Emerging Contributor

Hello,

I’m having issue with AGSServiceFeatureTable queryFeatures function, when I call it I get the error bellow.

 

I’m running a simple query like this:

class ViewController: UIViewController { 

 

  private var featureTable: AGSServiceFeatureTable = { 

     let featureTable = AGSServiceFeatureTable(url: url)

      featureTable.requestConfiguration?.timeoutInterval = 30
      return featureTable

  }()

override func viewDidLoad() { 

     super.viewDidLoad()

      self.fetchFeatures()

}


 private func fetchFeatures() { 

     let queryParams = AGSQueryParameters()
     queryParams.whereClause = "1=1"
     self.featureTable.queryFeatures(with: queryParams, queryFeatureFields: .loadAll) { result, error in
              if let result = result {
                     var array: [NSMutableDictionary] = []
                     for object in result.featureEnumerator().allObjects {
                          array.append(object.attributes)
                     }
             }
         } 

   }

}

ArcGIS Runtime Error Occurred. Set a breakpoint on C++ exceptions to see the original callstack and context for this error:  Error Domain=com.esri.arcgis.runtime.error Code=1014 "Unable to open the database file" UserInfo={NSLocalizedFailureReason=, NSLocalizedDescription=Unable to open the database file, Additional Message=}

Some help would be great!

 

Thank you

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Or, I wonder if the featureTable is going out of scope before the queryFeatures() call can return. Are you seeing the error in the console or is that actually being returned to the completion block?

Try making featureTable an instance variable/property on the class.

View solution in original post

0 Kudos
10 Replies
Nicholas-Furness
Esri Regular Contributor

Can you share the layer URL? Is it publicly accessible for us to test against?

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Or, I wonder if the featureTable is going out of scope before the queryFeatures() call can return. Are you seeing the error in the console or is that actually being returned to the completion block?

Try making featureTable an instance variable/property on the class.

0 Kudos
MartinStamenkovski
Emerging Contributor

I updated the original post with code how I actually use it.

  • featureTable is global variable.
  • the error is not received in the error property in the completion block, but it is printed in the console.
  • This is not happening all the time, for example I push this view controller, perform fetch the features are loaded. Then I dismiss this controller, push it again, the error is shown and it will not fetch the features until the app is killed and launched again.
0 Kudos
Nicholas-Furness
Esri Regular Contributor

Thanks. Sounds like some in-memory feature table backing store is being deallocated when you dismiss the view controller. Can you add some error checking into your callback and see what the "error" provides? It might just reflect what you're seeing in the console, but you should be checking that at code level as a best practice anyway.

0 Kudos
MartinStamenkovski
Emerging Contributor

I do check the error at runtime of course, but for sake of simplicity I didn't include the error handling here.

Unfortunately the completion block is not even invoked after the error above.

0 Kudos
Nicholas-Furness
Esri Regular Contributor

In that case…

  1. is the error you get back in the callback the same as the one you see in the console?
  2. Have you tried setting the C++ breakpoint as suggested in the error message?
  3. Please explain more fully what your view controller navigation is doing.
    1. You say you dismiss the view controller. When you push it again, is it being reconstructed or reused?
    2. Is there a MapView in this workflow, or are you simply creating the ServiceFeatureTable and holding on to that?
    3. If you recreate the service feature table each time your view controller is pushed, does that help?
  4. An you explain why you're explicitly setting the timeout on the request configuration? I suspect that's actually not doing anything since you haven't explicitly set a request configuration object on there. By default Runtime uses the iOS defaults for these things. I don't think this will have anything to do with the issue you're seeing, but I'd like to understand why the default wasn't working for you.

Also, as asked before, are you able to share the feature service URL?

0 Kudos
MartinStamenkovski
Emerging Contributor

1. The completion block is not even invoked after the error, so I can't say that is the same or not.

2.Yes, here it is.

3.1. Yes everything is being reconstructed.
3.2. No MapView only AGSServiceFeatureTable.

3.3. Yes I'm recreating it every time the view controller is pushed, and its not helping.

4. I planned to lower the timeout when resource is not available, 60 seconds it's too much.

I will try to send you the feature layer url, I don't know if I'm allowed to share it publicly.

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Thanks.

If the completion block is not being called (sorry - I missed this in your last reply), it certainly seems the AGSServiceFeatureTable must be getting deallocated and going out of scope. You should either get a result or an error. Is the view controller being dismissed while the query is in process? 

Could you provide a simple reproducer app so we can look into it?

The URL could be helpful but at this point I think it's likely this could be reproducible with any service.

BTW, for the c++ exception, we'd want to see the stack trace.

0 Kudos
MartinStamenkovski
Emerging Contributor

After long debugging, I discovered what is the problem, I will try to explain as short as possible.

This view controller has an WTArchitectView from Wikitude SDK for AR functionality, and unfortunately somehow it deallocates the AGSServiceFeatureTable. Probably some memory issues in their sdk.

So now I'm querying the features before presenting this view controller, and everything is working as expected.

Thank you for your time and help.