XML deserializing for embedded resources slow down app startup in Xamarin Forms











up vote
0
down vote

favorite












I am working on a mobile application with Xamarin Forms for Android and iOS devices. There are two XML files (each around 12MB) that contain translation among two languages. Currently these files are embedded resources in the shared project and are deserialized in order to be used inside the application. I have made a (singleton) resource manager to search for translations in these files. The manager always run an initialize method at startup to deserialize the XML files and to prevent loading the XML files for every single time that a word should be searched. This increases the startup time; iOS on iPhone 8 takes 7s and Android on Samsung galaxy S8 takes 17s.



My questions:




  1. Is it correct to use these files as embedded resources in the shared project? If not what is the best practice to minimize the startup?

  2. Is reading and deserializing the XML files the best way to use those files?


Note that I have already searched but did not come to any conclusion from an experience point of view. Any advice (specially with some examples) is appreciated.



Update:



Here is a sample from the XMl file. But keep in mind that there are more than 50000 <word> tags in the original XML file.



<?xml version="1.0" encoding="utf-8"?>
<MyDictionary>
<word class="nn" comment="även samklang av andra sinnesintryck; allmänt &amp;quot;överensstämmelse&amp;quot;" lang="sv" value="harmoni">
<translation comment="also used of harmony of other sensory impressions; generally, &amp;quot;agreement&amp;quot;" value="harmony" />
<phonetic soundFile="harmoni.swf" value="harmonI:" />
<paradigm>
<inflection value="harmonien" />
<inflection value="harmonier" />
</paradigm>
<synonym level="4.4" value="balans" />
<synonym level="3.2" value="endräkt" />
<synonym level="3.8" value="samklang" />
<synonym level="3.3" value="samspel" />
<synonym level="3.4" value="sämja" />
<synonym level="3.0" value="välbefinnande" />
<see type="saldo" value="harmoni||harmoni..1||harmoni..nn.1" />
<example value="leva i harmoni med naturen">
<translation value="be at one with Nature" />
</example>
<derivation inflection="harmoniskt" value="harmonisk">
<translation value="harmonious; harmonic" />
</derivation>
<definition value="samklang av toner">
<translation value="the simultaneous combination of musical tones" />
</definition>
</word>
</MyDictionary>


For deserializing, first a model/object of the XML file has been made by using Paste Special (Paste XML as classes) function in Visual Studio. Then following method is used to perform the deserializing.



private MyDictionary Load(string fileName)
{
try
{
var ass = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
var resourceName = $"LexinApp.XmlResources.{fileName}";
using (Stream stream = ass.GetManifestResourceStream(resourceName))
{
using (StreamReader reader = new StreamReader(stream))
{
var serializer = new XmlSerializer(typeof(MyDictionary));
return serializer.Deserialize(reader) as MyDictionary;
}
}
}
catch (Exception) { }

return null;
}


After that a word is searched by



var a = MyDictionary.word.Where(x => x.value == searchKey.ToLower()).ToList();









share|improve this question
























  • Could you show the code which does the deserializing or at least if that is too much an abbreviated version of it? In terms of performance due my experience is that using XDocument and XPath has a big impact on performance, since gathering the XDocument from the xml file is quite consuming. Even though it is a bit more work, you get an impressive performance gain by parsing the document "manually" using a XmlReader and creating the classes while running through the document tree.
    – Markus Michel
    Nov 9 at 8:22










  • @MarkusMichel Thanks for your answer. I have updated my question with further information.
    – utvecklare
    Nov 9 at 8:52















up vote
0
down vote

favorite












I am working on a mobile application with Xamarin Forms for Android and iOS devices. There are two XML files (each around 12MB) that contain translation among two languages. Currently these files are embedded resources in the shared project and are deserialized in order to be used inside the application. I have made a (singleton) resource manager to search for translations in these files. The manager always run an initialize method at startup to deserialize the XML files and to prevent loading the XML files for every single time that a word should be searched. This increases the startup time; iOS on iPhone 8 takes 7s and Android on Samsung galaxy S8 takes 17s.



My questions:




  1. Is it correct to use these files as embedded resources in the shared project? If not what is the best practice to minimize the startup?

  2. Is reading and deserializing the XML files the best way to use those files?


Note that I have already searched but did not come to any conclusion from an experience point of view. Any advice (specially with some examples) is appreciated.



Update:



Here is a sample from the XMl file. But keep in mind that there are more than 50000 <word> tags in the original XML file.



<?xml version="1.0" encoding="utf-8"?>
<MyDictionary>
<word class="nn" comment="även samklang av andra sinnesintryck; allmänt &amp;quot;överensstämmelse&amp;quot;" lang="sv" value="harmoni">
<translation comment="also used of harmony of other sensory impressions; generally, &amp;quot;agreement&amp;quot;" value="harmony" />
<phonetic soundFile="harmoni.swf" value="harmonI:" />
<paradigm>
<inflection value="harmonien" />
<inflection value="harmonier" />
</paradigm>
<synonym level="4.4" value="balans" />
<synonym level="3.2" value="endräkt" />
<synonym level="3.8" value="samklang" />
<synonym level="3.3" value="samspel" />
<synonym level="3.4" value="sämja" />
<synonym level="3.0" value="välbefinnande" />
<see type="saldo" value="harmoni||harmoni..1||harmoni..nn.1" />
<example value="leva i harmoni med naturen">
<translation value="be at one with Nature" />
</example>
<derivation inflection="harmoniskt" value="harmonisk">
<translation value="harmonious; harmonic" />
</derivation>
<definition value="samklang av toner">
<translation value="the simultaneous combination of musical tones" />
</definition>
</word>
</MyDictionary>


For deserializing, first a model/object of the XML file has been made by using Paste Special (Paste XML as classes) function in Visual Studio. Then following method is used to perform the deserializing.



private MyDictionary Load(string fileName)
{
try
{
var ass = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
var resourceName = $"LexinApp.XmlResources.{fileName}";
using (Stream stream = ass.GetManifestResourceStream(resourceName))
{
using (StreamReader reader = new StreamReader(stream))
{
var serializer = new XmlSerializer(typeof(MyDictionary));
return serializer.Deserialize(reader) as MyDictionary;
}
}
}
catch (Exception) { }

return null;
}


After that a word is searched by



var a = MyDictionary.word.Where(x => x.value == searchKey.ToLower()).ToList();









share|improve this question
























  • Could you show the code which does the deserializing or at least if that is too much an abbreviated version of it? In terms of performance due my experience is that using XDocument and XPath has a big impact on performance, since gathering the XDocument from the xml file is quite consuming. Even though it is a bit more work, you get an impressive performance gain by parsing the document "manually" using a XmlReader and creating the classes while running through the document tree.
    – Markus Michel
    Nov 9 at 8:22










  • @MarkusMichel Thanks for your answer. I have updated my question with further information.
    – utvecklare
    Nov 9 at 8:52













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am working on a mobile application with Xamarin Forms for Android and iOS devices. There are two XML files (each around 12MB) that contain translation among two languages. Currently these files are embedded resources in the shared project and are deserialized in order to be used inside the application. I have made a (singleton) resource manager to search for translations in these files. The manager always run an initialize method at startup to deserialize the XML files and to prevent loading the XML files for every single time that a word should be searched. This increases the startup time; iOS on iPhone 8 takes 7s and Android on Samsung galaxy S8 takes 17s.



My questions:




  1. Is it correct to use these files as embedded resources in the shared project? If not what is the best practice to minimize the startup?

  2. Is reading and deserializing the XML files the best way to use those files?


Note that I have already searched but did not come to any conclusion from an experience point of view. Any advice (specially with some examples) is appreciated.



Update:



Here is a sample from the XMl file. But keep in mind that there are more than 50000 <word> tags in the original XML file.



<?xml version="1.0" encoding="utf-8"?>
<MyDictionary>
<word class="nn" comment="även samklang av andra sinnesintryck; allmänt &amp;quot;överensstämmelse&amp;quot;" lang="sv" value="harmoni">
<translation comment="also used of harmony of other sensory impressions; generally, &amp;quot;agreement&amp;quot;" value="harmony" />
<phonetic soundFile="harmoni.swf" value="harmonI:" />
<paradigm>
<inflection value="harmonien" />
<inflection value="harmonier" />
</paradigm>
<synonym level="4.4" value="balans" />
<synonym level="3.2" value="endräkt" />
<synonym level="3.8" value="samklang" />
<synonym level="3.3" value="samspel" />
<synonym level="3.4" value="sämja" />
<synonym level="3.0" value="välbefinnande" />
<see type="saldo" value="harmoni||harmoni..1||harmoni..nn.1" />
<example value="leva i harmoni med naturen">
<translation value="be at one with Nature" />
</example>
<derivation inflection="harmoniskt" value="harmonisk">
<translation value="harmonious; harmonic" />
</derivation>
<definition value="samklang av toner">
<translation value="the simultaneous combination of musical tones" />
</definition>
</word>
</MyDictionary>


For deserializing, first a model/object of the XML file has been made by using Paste Special (Paste XML as classes) function in Visual Studio. Then following method is used to perform the deserializing.



private MyDictionary Load(string fileName)
{
try
{
var ass = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
var resourceName = $"LexinApp.XmlResources.{fileName}";
using (Stream stream = ass.GetManifestResourceStream(resourceName))
{
using (StreamReader reader = new StreamReader(stream))
{
var serializer = new XmlSerializer(typeof(MyDictionary));
return serializer.Deserialize(reader) as MyDictionary;
}
}
}
catch (Exception) { }

return null;
}


After that a word is searched by



var a = MyDictionary.word.Where(x => x.value == searchKey.ToLower()).ToList();









share|improve this question















I am working on a mobile application with Xamarin Forms for Android and iOS devices. There are two XML files (each around 12MB) that contain translation among two languages. Currently these files are embedded resources in the shared project and are deserialized in order to be used inside the application. I have made a (singleton) resource manager to search for translations in these files. The manager always run an initialize method at startup to deserialize the XML files and to prevent loading the XML files for every single time that a word should be searched. This increases the startup time; iOS on iPhone 8 takes 7s and Android on Samsung galaxy S8 takes 17s.



My questions:




  1. Is it correct to use these files as embedded resources in the shared project? If not what is the best practice to minimize the startup?

  2. Is reading and deserializing the XML files the best way to use those files?


Note that I have already searched but did not come to any conclusion from an experience point of view. Any advice (specially with some examples) is appreciated.



Update:



Here is a sample from the XMl file. But keep in mind that there are more than 50000 <word> tags in the original XML file.



<?xml version="1.0" encoding="utf-8"?>
<MyDictionary>
<word class="nn" comment="även samklang av andra sinnesintryck; allmänt &amp;quot;överensstämmelse&amp;quot;" lang="sv" value="harmoni">
<translation comment="also used of harmony of other sensory impressions; generally, &amp;quot;agreement&amp;quot;" value="harmony" />
<phonetic soundFile="harmoni.swf" value="harmonI:" />
<paradigm>
<inflection value="harmonien" />
<inflection value="harmonier" />
</paradigm>
<synonym level="4.4" value="balans" />
<synonym level="3.2" value="endräkt" />
<synonym level="3.8" value="samklang" />
<synonym level="3.3" value="samspel" />
<synonym level="3.4" value="sämja" />
<synonym level="3.0" value="välbefinnande" />
<see type="saldo" value="harmoni||harmoni..1||harmoni..nn.1" />
<example value="leva i harmoni med naturen">
<translation value="be at one with Nature" />
</example>
<derivation inflection="harmoniskt" value="harmonisk">
<translation value="harmonious; harmonic" />
</derivation>
<definition value="samklang av toner">
<translation value="the simultaneous combination of musical tones" />
</definition>
</word>
</MyDictionary>


For deserializing, first a model/object of the XML file has been made by using Paste Special (Paste XML as classes) function in Visual Studio. Then following method is used to perform the deserializing.



private MyDictionary Load(string fileName)
{
try
{
var ass = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
var resourceName = $"LexinApp.XmlResources.{fileName}";
using (Stream stream = ass.GetManifestResourceStream(resourceName))
{
using (StreamReader reader = new StreamReader(stream))
{
var serializer = new XmlSerializer(typeof(MyDictionary));
return serializer.Deserialize(reader) as MyDictionary;
}
}
}
catch (Exception) { }

return null;
}


After that a word is searched by



var a = MyDictionary.word.Where(x => x.value == searchKey.ToLower()).ToList();






xml performance xamarin.forms startup embedded-resource






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 12:53

























asked Nov 9 at 8:16









utvecklare

42611023




42611023












  • Could you show the code which does the deserializing or at least if that is too much an abbreviated version of it? In terms of performance due my experience is that using XDocument and XPath has a big impact on performance, since gathering the XDocument from the xml file is quite consuming. Even though it is a bit more work, you get an impressive performance gain by parsing the document "manually" using a XmlReader and creating the classes while running through the document tree.
    – Markus Michel
    Nov 9 at 8:22










  • @MarkusMichel Thanks for your answer. I have updated my question with further information.
    – utvecklare
    Nov 9 at 8:52


















  • Could you show the code which does the deserializing or at least if that is too much an abbreviated version of it? In terms of performance due my experience is that using XDocument and XPath has a big impact on performance, since gathering the XDocument from the xml file is quite consuming. Even though it is a bit more work, you get an impressive performance gain by parsing the document "manually" using a XmlReader and creating the classes while running through the document tree.
    – Markus Michel
    Nov 9 at 8:22










  • @MarkusMichel Thanks for your answer. I have updated my question with further information.
    – utvecklare
    Nov 9 at 8:52
















Could you show the code which does the deserializing or at least if that is too much an abbreviated version of it? In terms of performance due my experience is that using XDocument and XPath has a big impact on performance, since gathering the XDocument from the xml file is quite consuming. Even though it is a bit more work, you get an impressive performance gain by parsing the document "manually" using a XmlReader and creating the classes while running through the document tree.
– Markus Michel
Nov 9 at 8:22




Could you show the code which does the deserializing or at least if that is too much an abbreviated version of it? In terms of performance due my experience is that using XDocument and XPath has a big impact on performance, since gathering the XDocument from the xml file is quite consuming. Even though it is a bit more work, you get an impressive performance gain by parsing the document "manually" using a XmlReader and creating the classes while running through the document tree.
– Markus Michel
Nov 9 at 8:22












@MarkusMichel Thanks for your answer. I have updated my question with further information.
– utvecklare
Nov 9 at 8:52




@MarkusMichel Thanks for your answer. I have updated my question with further information.
– utvecklare
Nov 9 at 8:52












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










My best guess is that the xmlserializer isn't the fastest of its kind, especially since your word class has some degree of complexity.



As I already suggested in my comment, you might get quite a performance gain by ditching the xml serializer, write a custom xml parser based on XmlReader and push your data through it.



Another (or additional) idea to detach the serialization of your xml from your app's startup time would be loading your xml in an async background task so your main UI won't have to wait for it and since you have two files, you could also try loading them using parallel threading (using System.Collections.Concurrent):



string xmlFileNames = new string { "filenameA.xml", "filenameB.xml" };

Parallel.ForEach(xmlFileNames, xmlFile =>
{
Load(xmlFile);
});





share|improve this answer























  • OK! I'll give this a try. But is it good idea at all to have the XML files as embedded resources?
    – utvecklare
    Nov 9 at 9:15










  • Definitely. First, that is no dynamic content so it is a good idea to have it shipped within your app and second putting it into shared code instead of placing it within the native implementations saves you from the necessity of having to make the same changes to two files and enables you to just change one file instead and having the changes in all your resulting app versions. Actually I am currently implementing a localization plugin (based on json though, since our API uses the json format alread) in a similar way.
    – Markus Michel
    Nov 9 at 9:23












  • Parallel.Foreach changed the iOS app startup from 7s to 5s and Android app startup from 17s to 9s. I call this a good improvement. Thanks for your answers.
    – utvecklare
    Nov 9 at 22:13












  • You're welcome. Glad to hear it worked.
    – Markus Michel
    Nov 9 at 22:20










  • Investigated the issue more. Turned out .NET XMLSerializer is too slow when it comes to the deserializing. Then onStart() of my shared project had simply called the Initialize() method of DatabaseHandler. It was in the Initialize() method that Parallel.ForEach was called. This further improved by running the Initialize() on a Task like Task.Run(() => DatabaseHandler.Instance.Initialize());. This helped significantly a lot to show the fully functional UI. Meanwhile the XML files get deserialized without interrupting the UI. Now iOS loads in 1.5s and Android in 2.5s.
    – utvecklare
    Nov 20 at 9:51











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222022%2fxml-deserializing-for-embedded-resources-slow-down-app-startup-in-xamarin-forms%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










My best guess is that the xmlserializer isn't the fastest of its kind, especially since your word class has some degree of complexity.



As I already suggested in my comment, you might get quite a performance gain by ditching the xml serializer, write a custom xml parser based on XmlReader and push your data through it.



Another (or additional) idea to detach the serialization of your xml from your app's startup time would be loading your xml in an async background task so your main UI won't have to wait for it and since you have two files, you could also try loading them using parallel threading (using System.Collections.Concurrent):



string xmlFileNames = new string { "filenameA.xml", "filenameB.xml" };

Parallel.ForEach(xmlFileNames, xmlFile =>
{
Load(xmlFile);
});





share|improve this answer























  • OK! I'll give this a try. But is it good idea at all to have the XML files as embedded resources?
    – utvecklare
    Nov 9 at 9:15










  • Definitely. First, that is no dynamic content so it is a good idea to have it shipped within your app and second putting it into shared code instead of placing it within the native implementations saves you from the necessity of having to make the same changes to two files and enables you to just change one file instead and having the changes in all your resulting app versions. Actually I am currently implementing a localization plugin (based on json though, since our API uses the json format alread) in a similar way.
    – Markus Michel
    Nov 9 at 9:23












  • Parallel.Foreach changed the iOS app startup from 7s to 5s and Android app startup from 17s to 9s. I call this a good improvement. Thanks for your answers.
    – utvecklare
    Nov 9 at 22:13












  • You're welcome. Glad to hear it worked.
    – Markus Michel
    Nov 9 at 22:20










  • Investigated the issue more. Turned out .NET XMLSerializer is too slow when it comes to the deserializing. Then onStart() of my shared project had simply called the Initialize() method of DatabaseHandler. It was in the Initialize() method that Parallel.ForEach was called. This further improved by running the Initialize() on a Task like Task.Run(() => DatabaseHandler.Instance.Initialize());. This helped significantly a lot to show the fully functional UI. Meanwhile the XML files get deserialized without interrupting the UI. Now iOS loads in 1.5s and Android in 2.5s.
    – utvecklare
    Nov 20 at 9:51















up vote
0
down vote



accepted










My best guess is that the xmlserializer isn't the fastest of its kind, especially since your word class has some degree of complexity.



As I already suggested in my comment, you might get quite a performance gain by ditching the xml serializer, write a custom xml parser based on XmlReader and push your data through it.



Another (or additional) idea to detach the serialization of your xml from your app's startup time would be loading your xml in an async background task so your main UI won't have to wait for it and since you have two files, you could also try loading them using parallel threading (using System.Collections.Concurrent):



string xmlFileNames = new string { "filenameA.xml", "filenameB.xml" };

Parallel.ForEach(xmlFileNames, xmlFile =>
{
Load(xmlFile);
});





share|improve this answer























  • OK! I'll give this a try. But is it good idea at all to have the XML files as embedded resources?
    – utvecklare
    Nov 9 at 9:15










  • Definitely. First, that is no dynamic content so it is a good idea to have it shipped within your app and second putting it into shared code instead of placing it within the native implementations saves you from the necessity of having to make the same changes to two files and enables you to just change one file instead and having the changes in all your resulting app versions. Actually I am currently implementing a localization plugin (based on json though, since our API uses the json format alread) in a similar way.
    – Markus Michel
    Nov 9 at 9:23












  • Parallel.Foreach changed the iOS app startup from 7s to 5s and Android app startup from 17s to 9s. I call this a good improvement. Thanks for your answers.
    – utvecklare
    Nov 9 at 22:13












  • You're welcome. Glad to hear it worked.
    – Markus Michel
    Nov 9 at 22:20










  • Investigated the issue more. Turned out .NET XMLSerializer is too slow when it comes to the deserializing. Then onStart() of my shared project had simply called the Initialize() method of DatabaseHandler. It was in the Initialize() method that Parallel.ForEach was called. This further improved by running the Initialize() on a Task like Task.Run(() => DatabaseHandler.Instance.Initialize());. This helped significantly a lot to show the fully functional UI. Meanwhile the XML files get deserialized without interrupting the UI. Now iOS loads in 1.5s and Android in 2.5s.
    – utvecklare
    Nov 20 at 9:51













up vote
0
down vote



accepted







up vote
0
down vote



accepted






My best guess is that the xmlserializer isn't the fastest of its kind, especially since your word class has some degree of complexity.



As I already suggested in my comment, you might get quite a performance gain by ditching the xml serializer, write a custom xml parser based on XmlReader and push your data through it.



Another (or additional) idea to detach the serialization of your xml from your app's startup time would be loading your xml in an async background task so your main UI won't have to wait for it and since you have two files, you could also try loading them using parallel threading (using System.Collections.Concurrent):



string xmlFileNames = new string { "filenameA.xml", "filenameB.xml" };

Parallel.ForEach(xmlFileNames, xmlFile =>
{
Load(xmlFile);
});





share|improve this answer














My best guess is that the xmlserializer isn't the fastest of its kind, especially since your word class has some degree of complexity.



As I already suggested in my comment, you might get quite a performance gain by ditching the xml serializer, write a custom xml parser based on XmlReader and push your data through it.



Another (or additional) idea to detach the serialization of your xml from your app's startup time would be loading your xml in an async background task so your main UI won't have to wait for it and since you have two files, you could also try loading them using parallel threading (using System.Collections.Concurrent):



string xmlFileNames = new string { "filenameA.xml", "filenameB.xml" };

Parallel.ForEach(xmlFileNames, xmlFile =>
{
Load(xmlFile);
});






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 9 at 9:31

























answered Nov 9 at 9:06









Markus Michel

1,402214




1,402214












  • OK! I'll give this a try. But is it good idea at all to have the XML files as embedded resources?
    – utvecklare
    Nov 9 at 9:15










  • Definitely. First, that is no dynamic content so it is a good idea to have it shipped within your app and second putting it into shared code instead of placing it within the native implementations saves you from the necessity of having to make the same changes to two files and enables you to just change one file instead and having the changes in all your resulting app versions. Actually I am currently implementing a localization plugin (based on json though, since our API uses the json format alread) in a similar way.
    – Markus Michel
    Nov 9 at 9:23












  • Parallel.Foreach changed the iOS app startup from 7s to 5s and Android app startup from 17s to 9s. I call this a good improvement. Thanks for your answers.
    – utvecklare
    Nov 9 at 22:13












  • You're welcome. Glad to hear it worked.
    – Markus Michel
    Nov 9 at 22:20










  • Investigated the issue more. Turned out .NET XMLSerializer is too slow when it comes to the deserializing. Then onStart() of my shared project had simply called the Initialize() method of DatabaseHandler. It was in the Initialize() method that Parallel.ForEach was called. This further improved by running the Initialize() on a Task like Task.Run(() => DatabaseHandler.Instance.Initialize());. This helped significantly a lot to show the fully functional UI. Meanwhile the XML files get deserialized without interrupting the UI. Now iOS loads in 1.5s and Android in 2.5s.
    – utvecklare
    Nov 20 at 9:51


















  • OK! I'll give this a try. But is it good idea at all to have the XML files as embedded resources?
    – utvecklare
    Nov 9 at 9:15










  • Definitely. First, that is no dynamic content so it is a good idea to have it shipped within your app and second putting it into shared code instead of placing it within the native implementations saves you from the necessity of having to make the same changes to two files and enables you to just change one file instead and having the changes in all your resulting app versions. Actually I am currently implementing a localization plugin (based on json though, since our API uses the json format alread) in a similar way.
    – Markus Michel
    Nov 9 at 9:23












  • Parallel.Foreach changed the iOS app startup from 7s to 5s and Android app startup from 17s to 9s. I call this a good improvement. Thanks for your answers.
    – utvecklare
    Nov 9 at 22:13












  • You're welcome. Glad to hear it worked.
    – Markus Michel
    Nov 9 at 22:20










  • Investigated the issue more. Turned out .NET XMLSerializer is too slow when it comes to the deserializing. Then onStart() of my shared project had simply called the Initialize() method of DatabaseHandler. It was in the Initialize() method that Parallel.ForEach was called. This further improved by running the Initialize() on a Task like Task.Run(() => DatabaseHandler.Instance.Initialize());. This helped significantly a lot to show the fully functional UI. Meanwhile the XML files get deserialized without interrupting the UI. Now iOS loads in 1.5s and Android in 2.5s.
    – utvecklare
    Nov 20 at 9:51
















OK! I'll give this a try. But is it good idea at all to have the XML files as embedded resources?
– utvecklare
Nov 9 at 9:15




OK! I'll give this a try. But is it good idea at all to have the XML files as embedded resources?
– utvecklare
Nov 9 at 9:15












Definitely. First, that is no dynamic content so it is a good idea to have it shipped within your app and second putting it into shared code instead of placing it within the native implementations saves you from the necessity of having to make the same changes to two files and enables you to just change one file instead and having the changes in all your resulting app versions. Actually I am currently implementing a localization plugin (based on json though, since our API uses the json format alread) in a similar way.
– Markus Michel
Nov 9 at 9:23






Definitely. First, that is no dynamic content so it is a good idea to have it shipped within your app and second putting it into shared code instead of placing it within the native implementations saves you from the necessity of having to make the same changes to two files and enables you to just change one file instead and having the changes in all your resulting app versions. Actually I am currently implementing a localization plugin (based on json though, since our API uses the json format alread) in a similar way.
– Markus Michel
Nov 9 at 9:23














Parallel.Foreach changed the iOS app startup from 7s to 5s and Android app startup from 17s to 9s. I call this a good improvement. Thanks for your answers.
– utvecklare
Nov 9 at 22:13






Parallel.Foreach changed the iOS app startup from 7s to 5s and Android app startup from 17s to 9s. I call this a good improvement. Thanks for your answers.
– utvecklare
Nov 9 at 22:13














You're welcome. Glad to hear it worked.
– Markus Michel
Nov 9 at 22:20




You're welcome. Glad to hear it worked.
– Markus Michel
Nov 9 at 22:20












Investigated the issue more. Turned out .NET XMLSerializer is too slow when it comes to the deserializing. Then onStart() of my shared project had simply called the Initialize() method of DatabaseHandler. It was in the Initialize() method that Parallel.ForEach was called. This further improved by running the Initialize() on a Task like Task.Run(() => DatabaseHandler.Instance.Initialize());. This helped significantly a lot to show the fully functional UI. Meanwhile the XML files get deserialized without interrupting the UI. Now iOS loads in 1.5s and Android in 2.5s.
– utvecklare
Nov 20 at 9:51




Investigated the issue more. Turned out .NET XMLSerializer is too slow when it comes to the deserializing. Then onStart() of my shared project had simply called the Initialize() method of DatabaseHandler. It was in the Initialize() method that Parallel.ForEach was called. This further improved by running the Initialize() on a Task like Task.Run(() => DatabaseHandler.Instance.Initialize());. This helped significantly a lot to show the fully functional UI. Meanwhile the XML files get deserialized without interrupting the UI. Now iOS loads in 1.5s and Android in 2.5s.
– utvecklare
Nov 20 at 9:51


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222022%2fxml-deserializing-for-embedded-resources-slow-down-app-startup-in-xamarin-forms%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

JBPM : POST request for execute process go wrong