Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] MLNRasterStyleLayer gets cut off with mask in StyleURL file since v6.0 #2189

Closed
NicolasBrunnerSRF opened this issue Mar 12, 2024 · 13 comments · Fixed by #2242
Closed
Assignees
Labels
bug Something isn't working iOS metal

Comments

@NicolasBrunnerSRF
Copy link

Describe the bug
MLNRasterStyleLayer is cut off/masked by the mask defined in StyleURL JSON file, even though it should not.

See demo app: MapLibreMaskBug on Github

This demo app sets a custom style to the MapView, which contains a mask to cut out Switzerland and mask all other countries. It then adds an ImageLayer on top of the map (to show precipitation data). This ImageLayer should not be cut/masked outside of Switzerland. This worked fine with the latest major release of MapLibre v5 but is broken since the introduction of v6. See ReadMe of demo app github repo for a detailed description.

To Reproduce

  1. Download demo app
  2. Build and run on simulator

Expected behavior
ImageLayer (MLNRasterStyleLayer) is not affected by StyleURL file.

Screenshots
See demo app github repo ReadMe.

Platform information (please complete the following information):

  • iOS 17.4
  • XCode 15.3
  • MapLibre iOS v6.2.0 (was fine in v5)

Additional context
We are currently in a deadlock situation in our project: Using MapLibre iOS v5 crashes our app on iOS 17.4 simulators with XCode 15.3. Also, we cannot use MapLibre iOS v6 due to the above bug. So we are currently stuck at using XCode 15.2

@NicolasBrunnerSRF NicolasBrunnerSRF added the bug Something isn't working label Mar 12, 2024
@r3econ
Copy link

r3econ commented Mar 12, 2024

I'm facing the same issue 🤔

@louwers
Copy link
Collaborator

louwers commented Mar 12, 2024

Thanks for the detailed bug report! cc @sjg-wdw

@sjg-wdw
Copy link
Collaborator

sjg-wdw commented Mar 12, 2024

Do we have a test case that covers this one?

@louwers
Copy link
Collaborator

louwers commented Mar 12, 2024

Probably not. We have a repro though: https://github.com/NicolasBrunnerSRF/mapLibreMaskBug/blob/main/mapLibreMaskBug/style.json

@NicolasBrunnerSRF @r3econ Any chance you could provide a minimal style that reproduces the problem? Ideally one that doesn't include a reference to your server?

@NicolasBrunnerSRF
Copy link
Author

@louwers yes, good idea!

I updated the demo project with a minimal style and the issue is still reproducable:
Simulator Screenshot - iPhone 15 Pro - 2024-03-13 at 09 09 49

@louwers
Copy link
Collaborator

louwers commented Mar 13, 2024

@NicolasBrunnerSRF Perfect! Thanks.

@sjg-wdw The style is here: NicolasBrunnerSRF/mapLibreMaskBug@582328f

@Armenm
Copy link

Armenm commented Mar 13, 2024

Hi @NicolasBrunnerSRF I updated my Xcode to 15.3 and our app is crashing too on iOS 17.4 with v5. I noticed that it's not crashing if I run on iOS 17.2 simulator. Is your crash related to MapLibre too?

I am going to open separate issue with the details.

@louwers
Copy link
Collaborator

louwers commented Mar 13, 2024

@Armenm Apple has neglected OpenGL simulation for years so it is expected that the simulator is malfunctioning with 5.x.x (which still used OpenGL). iOS 5.x.x is no longer supported going forward. But let's keep the discussion focussed on the problem reported and not digress. Feel free to create another discussion though.

@bsudekum
Copy link
Contributor

We're also suffering from this problem. Not sure if this is a helpful or not, but I'm seeing:

  • v6 + OpenGL works
  • v6 + Metal does not work

@stefankarschti
Copy link
Collaborator

stefankarschti commented Apr 8, 2024

@NicolasBrunnerSRF : as a quick fix you could add fill-opacity to the polygon. it looks like it won't work as expected without it.

later edit: actually that works intermittently. fill-opacity: 0.99 works every time.

...
    "layers": [
        {
            "id": "switzerland_mask",
            "type": "fill",
            "source": "switzerland",
            "layout": {
                "visibility": "visible"
            },
            "paint": {
                "fill-color": "#1A7AC5",
                "fill-opacity": 0.99
            }
        }
    ]

image

@sjg-wdw
Copy link
Collaborator

sjg-wdw commented Apr 8, 2024

That's interesting. Is this a bug in our newer version or something that was always a bit dodgy?

@stefankarschti
Copy link
Collaborator

I'm still investigating, but it looks like it's related to the internal layer ordering for rendering; the result being that the opaque fill layer writes the depth buffer and the image doesn't pass the depth test.

@NicolasBrunnerSRF
Copy link
Author

@stefankarschti I can confirm that the opacity workaround does work (also in a more complex scenario).
Also, thanks for the Draft PR, we're looking forward to it being merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iOS metal
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

7 participants