mapbox / mapbox/mapbox-maps-ios
Updating layer property on a timer causes 'MTLTextureDescriptor has height of zero' error
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Xcode version: 14.2
- iOS version: 16.2
- Devices affected: All
- Maps SDK Version: 10.11.0
## Observed behavior and steps to reproduce
Similar to [this link](https://www.mapbox.com/blog/building-cinematic-route-animations-with-mapboxgl), I was trying to create an animation showing a route that one of my users ran using the .lineGradient property and the .lineProgress operator. Code is linked below in a gist, but the idea is I'm trying to update the line gradient property with a new expression every 3 seconds to account for where we're at in the animation. Here's the code run every 3 seconds:
```
@objc func tick() {
DispatchQueue.global().async(execute: {
DispatchQueue.main.sync { [self] in
let animationPhase = (Date().timeIntervalSince1970 - startTime.timeIntervalSince1970) / 10;
let exp = Exp(.step) {
Exp(.lineProgress)
UIColor.red
animationPhase
UIColor.purple
}
do {
if let data = try? JSONEncoder().encode(exp.self),
let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) {
try mapView.mapboxMap.style.setLayerProperty(for: "route-layer", property: "line-gradient", value: jsonObject)
}
} catch {
// no op
}
}
})
}
```
The Error I get occurs after one or two times running the above code and looks like this:

To **reproduce** here's a gist I created with all my code: https://gist.github.com/maxmiranda/730c70c862bcff18af43cdba9791c9e5.
## Expected behavior
We should get a nice smooth animation of the route slowly appearing on the screen, like this: https://twitter.com/i/status/1549692421096751106.
## Notes / preliminary analysis
I've double checked that the Expression I'm trying to set for the line gradient is accurate and even tried to move the logic to the main thread in case it was a threading issue, but nothing is working.
I believe this is an issue with Mapbox trying to render the map on a set schedule and then I come in and try to update the map on a regular time interval and it's throwing the map out of sync in some way. If we are not allowed to set layer properties on a regular basis as I did, please provide some alternative to be able to create an animation of the route slowly appearing as they do in the article linked below.
## Additional links and references
https://www.mapbox.com/blog/building-cinematic-route-animations-with-mapboxgl
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction gist with Mapbox Maps SDK 10.11.0 and inspect the repeated style.setLayerProperty calls that update line-gradient every three seconds. Compare the behavior when the updates run on the main thread, then determine whether the route animation can complete without the MTLTextureDescriptor error or whether a supported alternative is needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- computer-graphics, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100