Select to view content in your preferred language

GenerateGeodatabase job is failing while downloading offline map

6714
27
Jump to solution
01-11-2017 09:42 PM
VinayPrabhakar
New Contributor

Hi All,

Since we have updated our SDK to 100.0.0 we are unable to download offline Geodatabase map in our xamarin Application.

We are referring the sample code given at Create an offline map—ArcGIS Runtime SDK for .NET | ArcGIS for Developers 

Only thing we are not doing exactly as of the sample code is passing extent because,Below code throwing exception for us.

 Envelope extent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope;
If I want to pass a generic extent which will cover all the map,What we need to pass in that case.
Before 100.0.0 we were  not passing any extent,In that case how everything was downloading smoothly?
If we are passing hard coded extent still no luck.
The Error I am getting is:
Job failed. Job error 22 User defined failure. Error while handling generate geodatabase job statu


0 Kudos
27 Replies
ChadYoder1
Occasional Contributor II

Bummer you are having such issues.  I've been pleasantly surprised with how few issues I've encountered using the v. 100.0.0 release.  And, in the case where issues were found, there are adequate workarounds in place or fixes provided.

If you elaborate more on the issues and/or provide code, it will make it much easier for you to get help.  Also, specifics on your dev and server environment and the devices/emulators you are working with would be helpful.

0 Kudos
VinayPrabhakar
New Contributor

Hi Chad,

I am having multiple issues,I am listing down the issues:

  • During download of Geodatabase sometimes application is getting crashed and sometimes it's working fine.

  • Once i am able to download Geodatabase successfully If I am trying to load the map from Geodatabase it's getting crashed.After Application is getting crashed if I am logging in again and trying to load the map I am able to do it.

  • Map is not getting loaded when internet of device is off

Code Snippet of Download Geodatabase:

public async Task MakeMapAvailableOffline(UtiliSyncMap map, bool isManualSyc = false)

{

try

{

int currentLayerCount = 0;

foreach (var mapService in map.MapServices)

{

string mapServiceUrl = mapService.ServiceUrl.ToString().Substring(0, mapService.ServiceUrl.ToString().LastIndexOf("/"));

int layerAssociated = Convert.ToInt32((mapService.ServiceUrl.ToString().Substring(mapService.ServiceUrl.ToString().LastIndexOf('/') + 1)));

if (mapServiceUrl.Equals("https://services1.arcgis.com/BqQ60RORKMjmx3jf/arcgis/rest/services/SF_AGOL_TEST/FeatureServer") || mapServiceUrl.Equals("https://services6.arcgis.com/ExtdhXSbhHKK7FFW/arcgis/rest/services/SSMH_midvale/FeatureServer") || mapServiceUrl.Equals("https://services1.arcgis.com/BqQ60RORKMjmx3jf/arcgis/rest/services/Outfall_Template/FeatureServer"))

{

currentLayerCount++;

int downloadedPercentage = getDownloadedPercentage(currentLayerCount, map.MapServices.Count);

Acr.UserDialogs.UserDialogs.Instance.HideLoading();

Acr.UserDialogs.UserDialogs.Instance.ShowLoading(string.Format("Downloading {0} of Layers", currentLayerCount, map.MapServices)); continue; } #endregion var credential = await AuthenticationManager.Current.GenerateCredentialAsync(new Uri(mapServiceUrl), "username", "password"); AuthenticationManager.Current.AddCredential(credential); try { currentLayerCount++; Acr.UserDialogs.UserDialogs.Instance.HideLoading(); int downloadedPercentage = getDownloadedPercentage(currentLayerCount, map.MapServices.Count); Acr.UserDialogs.UserDialogs.Instance.ShowLoading(string.Format("Downloading {0} of Layers", currentLayerCount, map.MapServices.Count));

Debug.WriteLine("Getting Service Info for " + mapService.ServiceUrl);

if (!Directory.Exists("/storage/emulated/0/SmartMaps/OfflineMaps"))

{

System.IO.Directory.CreateDirectory("/storage/emulated/0/SmartMaps/OfflineMaps");

}

#if __UWP__

string gdbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, $"{mapService.MapServiceId}.geodatabase");

#else

string gdbPath = Path.Combine("/storage/emulated/0/SmartMaps/OfflineMaps", $"{mapService.MapServiceId}.geodatabase");

#endif

if (isManualSyc && File.Exists(gdbPath))

{

File.Delete(gdbPath);

}

var featureServiceUri = new Uri(mapServiceUrl);

var gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(featureServiceUri);

//Saved extent details to setting file

double XMin = Convert.ToDouble(Settings.XMin);

double YMin = Convert.ToDouble(Settings.YMin);

double XMax = Convert.ToDouble(Settings.XMax);

double YMax = Convert.ToDouble(Settings.YMax);

int wkid = Convert.ToInt32(Settings.SpatialReference);

Envelope extent = new Envelope(XMin, YMin, XMax, YMax, new SpatialReference(wkid));

var generateGdbParams = await gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent);

generateGdbParams.SyncModel = SyncModel.Layer;

generateGdbParams.LayerOptions.Clear();

generateGdbParams.LayerOptions.Add(new GenerateLayerOption(layerAssociated));

generateGdbParams.ReturnAttachments = false;

GenerateGeodatabaseJob generateGdbJob = gdbSyncTask.GenerateGeodatabase(generateGdbParams, gdbPath);

generateGdbJob.JobChanged += OnGenerateGdbJobChanged;

var gdb = await generateGdbJob.GetResultAsync();

Debug.WriteLine("Submitted job #" + generateGdbJob.ServerJobId + " to create local geodatabase");

}

}

}

}

Code Snippet to display Maps:

if (UtiliSyncMap.IsMapDownloaded)

{

for (int i = 0; i < UtiliSyncMap.MapServices.Count; i++)
{


string gdbPath = Path.Combine("/storage/emulated/0/SmartMaps/OfflineMaps", $"{UtiliSyncMap.MapServices.MapServiceId}.geodatabase");


await CreateFeatureLayersAsync(gdbPath, map);
}

}

private async Task CreateFeatureLayersAsync(string gdbPath, Map myMap)

{

try

{

// check if the file is exists in the local drive or not.

if (File.Exists(gdbPath))

{

gdb = await Geodatabase.OpenAsync(gdbPath);

if (gdb.GeodatabaseFeatureTables.Count == 0)

throw new Exception("Downloaded geodatabase has no feature tables.");

GdbTables = gdb.GeodatabaseFeatureTables.ToList();

foreach (var gdbTable in gdb.GeodatabaseFeatureTables)

{

await gdbTable.LoadAsync();

var fl = new FeatureLayer(gdbTable);

FeatureLayers.Add(fl);

myMap.OperationalLayers.Add(fl);

}

}

FeaturesLoaded = true;

return myMap;

}

catch (Exception ex)

{

return null;

}

}

Thanks & Regards

Binay Prabhakar Yadav

Mobile: +91 8095648069

0 Kudos
ChadYoder1
Occasional Contributor II

Sounds like you definitely have some weird things going on.

Are you testing on an emulator?  If so, which one?  I periodically had issues using an emulator in the Beta version, but have not seen it with v. 100.0.0.

Sync Geodatabase:  

- If you are only syncing a single layer, why not just use the Geodatabase sync model?

- Does the error typically occur on the same service? 

Load map:

- If you start online, then switch to offline and load the map, I would also try creating a new Map before you load the layers.

- Might be good practice to check if the table has geometry.  GeodatabaseFeatureTable.HasGeometry property.

- If an error occurs on a specific database, have you checked that it's valid by just opening the database to view the contents?

Internet Off: 

- What is the workflow you are using to load the offline geodatabase?  Are the layers loaded when the application starts while offline?

- Make sure to create a new Map if you transition from online to offline.  

0 Kudos
VinayPrabhakar
New Contributor

Hi,

Sometimes I am getting below exception,I am unable to handle it from code(Try,Catch)

I got this error details from device log:

01-21 10:37:54.548 E/mono ( 3334): Unhandled Exception:

01-21 10:37:54.548 E/mono ( 3334): Esri.ArcGISRuntime.ArcGISRuntimeException: No data

Please help me to get rid of this,This issue is causing exception.

Note:This error is not happening always,It's happening 4 out of 10 times when downloading the map and loading it.The exception is also not from code

Thanks & Regards

Binay Prabhakar Yadav

Mobile: +91 8095648069

0 Kudos
VinayPrabhakar
New Contributor

Hi,

Below is the error log:

01-21 10:37:54.548 E/mono ( 3334): Unhandled Exception:

01-21 10:37:54.548 E/mono ( 3334): Esri.ArcGISRuntime.ArcGISRuntimeException: No data

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:447

01-21 10:37:54.548 E/mono ( 3334): at Esri.ArcGISRuntime.Tasks.Offline.GenerateGeodatabaseJob+d__2.MoveNext () in :0

01-21 10:37:54.548 E/mono ( 3334): --- End of stack trace from previous location where exception was thrown ---

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535

01-21 10:37:54.548 E/mono ( 3334): at Esri.ArcGISRuntime.Tasks.Job`1+<RuntimeCoreNet-GeneratedWrappers-ICoreCallback_Job_JobDone-JobDone>d__8.MoveNext () in :0

01-21 10:37:54.548 E/mono ( 3334): --- End of stack trace from previous location where exception was thrown ---

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143

01-21 10:37:54.548 E/mono ( 3334): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__1 (System.Object state) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1034

01-21 10:37:54.548 E/mono ( 3334): at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/threading/threadpool.cs:1307

01-21 10:37:54.548 E/mono ( 3334): at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, Boolean preserveSyncCtx) in /Users/builder/data/lanes/3540/1cf254db/source/mono/external/referencesource/mscorlib/system/thr

01-21 10:37:54.560 E/Runtime Core( 3334): 142 Graphics_hardware_resource or Device objects have not been destructed

01-21 10:37:54.574 E/mono-rt ( 3334): Stacktrace:

Thanks & Regards

Binay Prabhakar Yadav

Mobile: +91 8095648069

0 Kudos
ChadYoder1
Occasional Contributor II

What are the device specs you are testing on?  Emulator or real device?  OS, version, etc.

0 Kudos
VinayPrabhakar
New Contributor

Yes I am testing on Genymotion Simulator.

Even on my android device I am facing the same issue.App is getting crashed sometimes and sometimes is working smoothly.

But as per log I am 100% sure that issue is happening because of ArcGis code I am using to download and display the offline map.

Any help on this will be highly appreciated.I am giving this much of time on this issue still no outcome

Thanks & Regards

Binay Prabhakar Yadav

Mobile: +91 8095648069

0 Kudos
JoeHershman
MVP Regular Contributor

Did you ever get this figured out?  

Take a look at this thread: Map Failed To Download (Thread 2).  But to summarize, my experience is the Referenced data services published from ArcGIS Pro (even after going into Server Manager and turning on Sync) will not download.  If you publish from ArcMap all works fine

Thanks,
-Joe
0 Kudos