Lambdo-Labs/MDText

Crash when using long text

Closed this issue · 11 comments

When using slightly long text, you'll get a hard crash:

validateTextureDimensions, line 1230: error 'MTLTextureDescriptor has height (8797) greater than the maximum allowed size of 8192.'
validateTextureDimensions:1230: failed assertion `MTLTextureDescriptor has height (8797) greater than the maximum allowed size of 8192.'
**Early life**
Ragnar’s mother Audhild Strongheart, a Shield Dwarf, was born and raised in Citadel Adbar in the Silver Marches. She’s a fine looking lady with pale skin, blue eyes and light red hair; thick curls that reach her shoulders. Audhild trained to be a cleric of Clangeddin Silverbeard and as part of her duties she was sent to Eartheart at the Great Rift where she met Sigurd Ironfist, Ragnar's father.

Sigurd, a Mountain Dwarf, was born and raised in Underhome but stationed in Eartheart's military camp where he is still an officer. He has dark tan skin, almost black hair and a glorious beard that reaches his belt. He met Audhild in an inn when they were both off duty. The two fell in love, quickly married and had 3 children: eldest daughter Thorunn and 10 years later the identical twins Ragnar and Rurik (Ragnar is 4 minutes older, a fact he'd often mention to his "younger" brother). While Thorunn looks very much like her mom, the two brothers are more of a mixture of their parents' heritage: a light tan skin, light brown hair and dark blue eyes.

Ragnar did not have an easy time in school. He was bullied because of his mixed blood and because of that was not very social with other kids. He's still a bit of an awkward loner today. He also sometimes got in trouble for stuff that his twin brother Rurik did, which would typically result in a fistfight back home. Ragnar usually won.

He loves his sister Thorunn to death. She lives in Underhome with the Ironfist clan and works as a brewer. She taught him a thing or two and it became a pretty serious hobby for Ragnar. Thorunn is currently engaged to Floki Grayhammer, Ragnar's shieldbrother from his military days and best friend whom he trusts with his life.

Rurik is the black sheep of the family: his mischievous childhood turned into a life of crime and when the law was on to him, he fled Eartheart a few years ago. Ragnar does not know where Rurik currently is, or if he is even alive.

**Military**
As soon as he was able to join the military, he did, at the suggestion of his father. After all, he seemed like he could handle himself in a fight, didn’t like school, was loyal to his (few) friends and it would be a great honor to follow his fathers footsteps, as he did before him.

Indeed, Ragnar was very much suited to military life, the discipline and authority. His direct no- nonsense approach to problem solving was useful, and combined with his wits and insight he quickly rose through the ranks to become an officer.

Ragnar was often stationed at one of the Riftedge Towers and sometimes went on patrol duty in the Underdark. It was in one of the Riftedge Towers that he met Floki. The two bonded initially over beer recipes and he decided to introduce him to his sister over a double date. Sadly Ragnar's date wasn't a keeper, but Floki and Thorunn hit it off.

Overall, his time in the military was joyful and the people he served with remember him fondly. They didn’t care if he was a half-blood, just that they could trust him with their lives.

**Becoming a cleric of Clangeddin**
One day, a group of filthy Duergar ambushed sergeant Ragnar's patrol group in the Underdark. Outnumbered and surprised, the Dwarves quickly began to lose control of the battlefield and all hope seemed lost. Ragnar, bleeding heavily and desperate to save his men shouted to his god: "Clangeddin, my life for my men! Save them please!"

Immediately, Ragnar found a new strength in him. A second gear, no, a third gear even. It was as if someone was helping him to wield his sword: every strike hit harder and more accurate with less effort, and he stroke down with great vengeance and furious anger upon those who attempted to destroy his brothers. His men also seemed stronger, and together they killed all the Duergar without loosing a single soul themselves. A miracle.

The surviving Dwarves later told Ragnar that his eyes glowed and holy symbols of Clangeddin appeared on his skin as he was slaying the Duergar. His mother (a cleric of Clangeddin) couldn’t be more proud!

Ragnar got a medal and a promotion and joined the clerics of Clangeddin in the military encampment and trained with them, pledging his life in service to the Father of Battle. He shaved his head and had holy symbols and runes tattooed on his skull, honoring that faithful day of the ambush.

**Choosing a life of adventure**
Some years later Ragnar, now First Lieutenant, felt that his life was being wasted in the standing army of Eartheart. He felt he needed to do more in service of Clangeddin, and sought a way out from the military. Luckily his father and mother supported his decision and found him a noble cause to join: a big caravan was heading north through the Underdark, and they could surely use his help and expertise. And so it began...

Same issue. This is the text I'm trying to insert:

## Terms & Conditions

By downloading or using the app, these terms will automatically apply to you – you should make sure therefore that you read them carefully before using the app. You’re not allowed to copy, or modify the app, any part of the app, or our trademarks in any way. You’re not allowed to attempt to extract the source code of the app, and you also shouldn’t try to translate the app into other languages, or make derivative versions. The app itself, and all the trade marks, copyright, database rights and other intellectual property rights related to it, still belong to [Developer/Company name].

[Developer/Company name] is committed to ensuring that the app is as useful and efficient as possible. For that reason, we reserve the right to make changes to the app or to charge for its services, at any time and for any reason. We will never charge you for the app or its services without making it very clear to you exactly what you’re paying for.

The [App Name] app stores and processes personal data that you have provided to us, in order to provide [my/our] Service. It’s your responsibility to keep your phone and access to the app secure. We therefore recommend that you do not jailbreak or root your phone, which is the process of removing software restrictions and limitations imposed by the official operating system of your device. It could make your phone vulnerable to malware/viruses/malicious programs, compromise your phone’s security features and it could mean that the [App Name] app won’t work properly or at all.

You should be aware that there are certain things that [Developer/Company name] will not take responsibility for. Certain functions of the app will require the app to have an active internet connection. The connection can be Wi-Fi, or provided by your mobile network provider, but [Developer/Company name] cannot take responsibility for the app not working at full functionality if you don’t have access to Wi-Fi, and you don’t have any of your data allowance left.

If you’re using the app outside of an area with Wi-Fi, you should remember that your terms of the agreement with your mobile network provider will still apply. As a result, you may be charged by your mobile provider for the cost of data for the duration of the connection while accessing the app, or other third party charges. In using the app, you’re accepting responsibility for any such charges, including roaming data charges if you use the app outside of your home territory (i.e. region or country) without turning off data roaming. If you are not the bill payer for the device on which you’re using the app, please be aware that we assume that you have received permission from the bill payer for using the app.

Along the same lines, [Developer/Company name] cannot always take responsibility for the way you use the app i.e. You need to make sure that your device stays charged – if it runs out of battery and you can’t turn it on to avail the Service, [Developer/Company name] cannot accept responsibility.

With respect to [Developer/Company name]’s responsibility for your use of the app, when you’re using the app, it’s important to bear in mind that although we endeavour to ensure that it is updated and correct at all times, we do rely on third parties to provide information to us so that we can make it available to you. [Developer/Company name] accepts no liability for any loss, direct or indirect, you experience as a result of relying wholly on this functionality of the app.

At some point, we may wish to update the app. The app is currently available on – the requirements for system (and for any additional systems we decide to extend the availability of the app to) may change, and you’ll need to download the updates if you want to keep using the app. [Developer/Company name] does not promise that it will always update the app so that it is relevant to you and/or works with the version that you have installed on your device. However, you promise to always accept updates to the application when offered to you, We may also wish to stop providing the app, and may terminate use of it at any time without giving notice of termination to you. Unless we tell you otherwise, upon any termination, (a) the rights and licenses granted to you in these terms will end; (b) you must stop using the app, and (if needed) delete it from your device.

**Changes to This Terms and Conditions**

[I/We] may update our Terms and Conditions from time to time. Thus, you are advised to review this page periodically for any changes. [I/We] will notify you of any changes by posting the new Terms and Conditions on this page. These changes are effective immediately after they are posted on this page.

**Contact Us**

If you have any questions or suggestions about [my/our] Terms and Conditions, do not hesitate to contact [me/us] at [App Contact informations].

This Terms and Conditions page was generated by [App Privacy Policy Generator](https://app-privacy-policy-generator.firebaseapp.com/)
Veeit commented

I have the same problem, I hope there is soon a solution for that

Any more information? what is the context? I included both of your texts in the included sample app in this repo and the app runs and renders just fine.

struct ContentView: View {
  var markdown =
  """
  **Early life**
  Ragnar’s mother Audhild Strongheart, a Shield Dwarf, was born and raised in Citadel Adbar in the Silver Marches. She’s a fine looking lady with pale skin, blue eyes and light red hair; thick curls that reach her shoulders. Audhild trained to be a cleric of Clangeddin Silverbeard and as part of her duties she was sent to Eartheart at the Great Rift where she met Sigurd Ironfist, Ragnar's father.

  Sigurd, a Mountain Dwarf, was born and raised in Underhome but stationed in Eartheart's military camp where he is still an officer. He has dark tan skin, almost black hair and a glorious beard that reaches his belt. He met Audhild in an inn when they were both off duty. The two fell in love, quickly married and had 3 children: eldest daughter Thorunn and 10 years later the identical twins Ragnar and Rurik (Ragnar is 4 minutes older, a fact he'd often mention to his "younger" brother). While Thorunn looks very much like her mom, the two brothers are more of a mixture of their parents' heritage: a light tan skin, light brown hair and dark blue eyes.

  Ragnar did not have an easy time in school. He was bullied because of his mixed blood and because of that was not very social with other kids. He's still a bit of an awkward loner today. He also sometimes got in trouble for stuff that his twin brother Rurik did, which would typically result in a fistfight back home. Ragnar usually won.

  He loves his sister Thorunn to death. She lives in Underhome with the Ironfist clan and works as a brewer. She taught him a thing or two and it became a pretty serious hobby for Ragnar. Thorunn is currently engaged to Floki Grayhammer, Ragnar's shieldbrother from his military days and best friend whom he trusts with his life.

  Rurik is the black sheep of the family: his mischievous childhood turned into a life of crime and when the law was on to him, he fled Eartheart a few years ago. Ragnar does not know where Rurik currently is, or if he is even alive.

  **Military**
  As soon as he was able to join the military, he did, at the suggestion of his father. After all, he seemed like he could handle himself in a fight, didn’t like school, was loyal to his (few) friends and it would be a great honor to follow his fathers footsteps, as he did before him.

  Indeed, Ragnar was very much suited to military life, the discipline and authority. His direct no- nonsense approach to problem solving was useful, and combined with his wits and insight he quickly rose through the ranks to become an officer.

  Ragnar was often stationed at one of the Riftedge Towers and sometimes went on patrol duty in the Underdark. It was in one of the Riftedge Towers that he met Floki. The two bonded initially over beer recipes and he decided to introduce him to his sister over a double date. Sadly Ragnar's date wasn't a keeper, but Floki and Thorunn hit it off.

  Overall, his time in the military was joyful and the people he served with remember him fondly. They didn’t care if he was a half-blood, just that they could trust him with their lives.

  **Becoming a cleric of Clangeddin**
  One day, a group of filthy Duergar ambushed sergeant Ragnar's patrol group in the Underdark. Outnumbered and surprised, the Dwarves quickly began to lose control of the battlefield and all hope seemed lost. Ragnar, bleeding heavily and desperate to save his men shouted to his god: "Clangeddin, my life for my men! Save them please!"

  Immediately, Ragnar found a new strength in him. A second gear, no, a third gear even. It was as if someone was helping him to wield his sword: every strike hit harder and more accurate with less effort, and he stroke down with great vengeance and furious anger upon those who attempted to destroy his brothers. His men also seemed stronger, and together they killed all the Duergar without loosing a single soul themselves. A miracle.

  The surviving Dwarves later told Ragnar that his eyes glowed and holy symbols of Clangeddin appeared on his skin as he was slaying the Duergar. His mother (a cleric of Clangeddin) couldn’t be more proud!

  Ragnar got a medal and a promotion and joined the clerics of Clangeddin in the military encampment and trained with them, pledging his life in service to the Father of Battle. He shaved his head and had holy symbols and runes tattooed on his skull, honoring that faithful day of the ambush.

  **Choosing a life of adventure**
  Some years later Ragnar, now First Lieutenant, felt that his life was being wasted in the standing army of Eartheart. He felt he needed to do more in service of Clangeddin, and sought a way out from the military. Luckily his father and mother supported his decision and found him a noble cause to join: a big caravan was heading north through the Underdark, and they could surely use his help and expertise. And so it began...
  """

  var body: some View {
    ScrollView {
      MDText(markdown: markdown)
    }
  }
}

Same if you replace ScrollView with List.

Xcode 11.3.1.

What version of the repo are you using? What device/OS are you running on?
Your code works in a sample project on release 0.0.6, with an iphone Xs on iOS 13.3.1. Xcode is 11.3.1 (11C504).

It actually works on the device (hadn't tested that before as I do all my development in the simulator really), but it crashes in the simulator. Same versions as you.

Veeit commented

I don't have the problem anymore with the newest version of the package 👍
Simulator and device seams to work fine for me. I'm using the Xcode beta and iOS 13.4, but with that installed I updated my swift ... so I don't have any problem with Xcode 11.3.1 (11C504) too. Maybe it is a swift problem that is fixed with the new version

Version 0.0.7 also works in the simulator now 🎉

In the latest I just removed .drawingGroup(). Maybe some simulators don’t like metal.
Closing this!