title: links crashing iOS Music app
body: <p>I'm trying to open a link to a track from my iOS app but the Music app randomly crashes.</p>
  
  <p>I get the track URL via the iTunes <a href="https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#searchexamples" rel="nofollow noreferrer">search API</a>.</p>
  
  <p>Here's an example trackURL extracted from the JSON response: <a href="https://itunes.apple.com/us/album/10-bagatelles-op.-5-bagatelle/id253254038?i=253254078&amp;uo=4&amp;partnerId=11" rel="nofollow noreferrer">https://itunes.apple.com/us/album/10-bagatelles-op.-5-bagatelle/id253254038?i=253254078&amp;uo=4&amp;partnerId=11</a></p>
  
  <p>I add my affiliate id (&amp;at=MYID) and the media type (&amp;mt=1) for music, along with &amp;app=music to open in Apple Music rather than iTunes (which would be &amp;app=itunes).
  I've tried it without the &amp;at and &amp;mt params and it still crashes. I've pasted the link into Safari (and Chrome) and it's a valid link; I see the appropriate page.</p>
  
  <p>To actually open the URL, I use</p>
  
  <pre><code>UIApplication.shared.openURL(url)
  </code></pre>
  
  <p>I've tried this way also:</p>
  
  <pre><code>let svc = SFSafariViewController(url: URL, entersReaderIfAvailable: false)
  svc.delegate = self
  self.present(svc, animated: true, completion: nil)
  </code></pre>
  
  <p>Sometimes everything works - the Music app opens, and goes to the track. It plays just fine. Then I go back to my app, try another link. and Music crashes. My app is still running. There is a crash log for Music. It says the problem is "attempted to retain deallocated object". I don't know what I personally can do about that. </p>
  
  <p>Any suggestions welcome.</p>
  
  <pre><code>Process:             Music [1100]
  Path:                /Applications/Music.app/Music
  Identifier:          com.apple.Music
  Version:             1.0 (3.0)
  Code Type:           ARM-64 (Native)
  Role:                Foreground
  Parent Process:      launchd [1]
  Coalition:           com.apple.Music [577]
  OS Version:          iPhone OS 10.2 (14C92)
  Report Version:      104
  Exception Type:  EXC_BREAKPOINT (SIGTRAP)
  Exception Codes: 0x0000000000000001, 0x00000001abd62c88
  Termination Signal: Trace/BPT trap: 5
  Termination Reason: Namespace SIGNAL, Code 0x5
  Terminating Process: exc handler [0]
  Triggered by Thread:  0
  Application Specific Information:
  attempted to retain deallocated object
  </code></pre>
  
  <p>I don't think I'm trying anything unusual. In fact, I think this is probably a common use-case for the iTunes search API.</p>
  
  <p>XCode 8.2.1, Swift 3, iOS 10.2, iPhone 6S+ also running iOS 10.2</p>