{"action":"created","issue":{"url":"https://api.github.com/repos/cbpowell/MarqueeLabel-Swift/issues/13","labels_url":"https://api.github.com/repos/cbpowell/MarqueeLabel-Swift/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/cbpowell/MarqueeLabel-Swift/issues/13/comments","events_url":"https://api.github.com/repos/cbpowell/MarqueeLabel-Swift/issues/13/events","html_url":"https://github.com/cbpowell/MarqueeLabel-Swift/issues/13","id":113543804,"number":13,"title":"Seemingly random crashes in applyGradientMask:animated:","user":{"login":"fletcher89","id":5980743,"avatar_url":"https://avatars.githubusercontent.com/u/5980743?v=3","gravatar_id":"","url":"https://api.github.com/users/fletcher89","html_url":"https://github.com/fletcher89","followers_url":"https://api.github.com/users/fletcher89/followers","following_url":"https://api.github.com/users/fletcher89/following{/other_user}","gists_url":"https://api.github.com/users/fletcher89/gists{/gist_id}","starred_url":"https://api.github.com/users/fletcher89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fletcher89/subscriptions","organizations_url":"https://api.github.com/users/fletcher89/orgs","repos_url":"https://api.github.com/users/fletcher89/repos","events_url":"https://api.github.com/users/fletcher89/events{/privacy}","received_events_url":"https://api.github.com/users/fletcher89/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-10-27T09:42:36Z","updated_at":"2015-11-30T16:40:38Z","closed_at":null,"body":"Hi,\r\n\r\nI've been using MarqueeLabel-Swift for the first time in the past few days. Unfortunately it seems like it's causing my app to crash. The crash is not consistent at all to reproduce, this is the first time I caught it in the debugger. I'm not sure what exactly is happening here or if it's even an issue with MarqueeLabel-Swift or maybe tvOS itself.\r\n\r\nThe call stack looks like this:\r\n\r\n![screen shot 2015-10-27 at 10 22 53](https://cloud.githubusercontent.com/assets/5980743/10754254/d25bdc50-7c96-11e5-96e8-ffb4ee205fe1.png)\r\n\r\nThe Exception breakpoint is fired at this line: \r\n\r\n[MarqueeLabel.swift#L709](https://github.com/cbpowell/MarqueeLabel-Swift/blob/9bde55ea0459a8ec3dbffc642df0a9ddbd385684/Classes/MarqueeLabel.swift#L709)"},"comment":{"url":"https://api.github.com/repos/cbpowell/MarqueeLabel-Swift/issues/comments/160683183","html_url":"https://github.com/cbpowell/MarqueeLabel-Swift/issues/13#issuecomment-160683183","issue_url":"https://api.github.com/repos/cbpowell/MarqueeLabel-Swift/issues/13","id":160683183,"user":{"login":"cbpowell","id":593953,"avatar_url":"https://avatars.githubusercontent.com/u/593953?v=3","gravatar_id":"","url":"https://api.github.com/users/cbpowell","html_url":"https://github.com/cbpowell","followers_url":"https://api.github.com/users/cbpowell/followers","following_url":"https://api.github.com/users/cbpowell/following{/other_user}","gists_url":"https://api.github.com/users/cbpowell/gists{/gist_id}","starred_url":"https://api.github.com/users/cbpowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbpowell/subscriptions","organizations_url":"https://api.github.com/users/cbpowell/orgs","repos_url":"https://api.github.com/users/cbpowell/repos","events_url":"https://api.github.com/users/cbpowell/events{/privacy}","received_events_url":"https://api.github.com/users/cbpowell/received_events","type":"User","site_admin":false},"created_at":"2015-11-30T16:40:38Z","updated_at":"2015-11-30T16:40:38Z","body":"Thanks for the feedback! That let me reproduce it, at least on iOS 8.4 in the simulator.\r\n\r\nSo I think @manuelolmos is on to a potential solution of just removing those lines. I was able to prevent the crash by commenting out [the lines](https://github.com/cbpowell/MarqueeLabel-Swift/blob/ba10d36c81da98f42f78a8d32b95cdce1d577ea8/Classes/MarqueeLabel.swift#L719-L720) that set the initial `locations` and `colors` values to the gradient mask layer, and didn't notice any negative side effects. The \"correct\" locations and colors are set just a little later in the function anyway.\r\n\r\nI was also able to prevent the crash by wrapping those lines (plus the surrounding) in a CATransaction that disabled the implicit animations:\r\n```swift\r\nCATransaction.begin()\r\nCATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions)\r\ngradientMask.bounds = self.layer.bounds\r\n// etc, etc...\r\n// Start with default (no fade) locations\r\ngradientMask.locations = [0.0, 0.0, 1.0, 1.0]\r\ngradientMask.colors = colors\r\nCATransaction.commit()\r\n```\r\n\r\nSo it seems like some issue with setting those values and the implicit CALayer animation that occurs we those values are changed.\r\n\r\n@fletcher89 / @AlexeyS - I'd suggest trying out the simple solution of just removing/commenting out those lines, and see if that fixes the issue for you guys?"}}