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

Features not showing up until zooming in #1436

Open
maxmiranda opened this issue Jul 8, 2022 · 8 comments
Open

Features not showing up until zooming in #1436

maxmiranda opened this issue Jul 8, 2022 · 8 comments
Labels
bug 🪲 Something is broken!

Comments

@maxmiranda
Copy link

Environment

  • Xcode version: 13.4.1
  • iOS version: 15.5
  • Devices affected: All
  • Maps SDK Version: 10.4.1

Observed behavior and steps to reproduce

In my app, I blanket the map with square features (aka blocks). Intermittently, these square features are not showing up on the map until I zoom in or zoom out. Then they render perfectly normally.

trimmed.bug.features.not.showing.mov

Expected behavior

When I load the app, all the features should be present.

Notes / preliminary analysis

I will admit, my app uses features in a somewhat complex way: we're storing information on who owns which blocks in our database. And the blocks only become visible once we fetch the info on block ownership and then set the feature state of the corresponding features to reflect the block ownership (we have layers that style the blocks based on the feature state).

HOWEVER, it is my theory that none of that is relevant. Because, when I zoom in or zoom out, there are NO database calls whatsoever. None of my code relating to: fetching block ownership info, setting up the map layers or source, or setting the feature state based on the block ownership gets called upon zoom in or zoom out. I don't think it's a race condition on my end either because i'm experiencing this issue intermittently but the order of us: adding the map overlay, fetching the database info, then setting the feature states doesn't change.

Additional links and references

I did find this issue which seems like it pertains to my issue, but it's for Mapbox GL Native, so i have no idea if it's relevatn: mapbox/mapbox-gl-native#1675.

Would very much appreciate someone looking into this!!

@maxmiranda maxmiranda added the bug 🪲 Something is broken! label Jul 8, 2022
@ZiZasaurus
Copy link
Contributor

@maxmiranda, we would be happy to look into this for you. Do you happen to have a minimal sample app you can provide that reproduces this behavior?

@maxmiranda
Copy link
Author

@ZiZasaurus thanks so much! I do not at the moment, I can try to create one but unsure how long that will take because it would have to involve re-creating a lot of the complex logic described above.

Happy to simply give you access to our repo if you want to play around with it.

@maxmiranda
Copy link
Author

@ZiZasaurus I'm now finding the issue has gotten worse and is occurring every single time a user opens the app. I would greatly appreciate your assistance on this. I've given you access to our repo, and I'd be happy to schedule some time on your calendar to explain in more detail what's going on.

@zhengping97
Copy link

@maxmiranda @ZiZasaurus Hi! Just wanna check if there is any update on this. I am not using IOS but I faced this issue on my web application as well (three.js 3D model not appearing until zooming in).

@sarath40158
Copy link

@mfazekas @macdrevx @maxmiranda
Any Update on this issue ?

@maxmiranda
Copy link
Author

Might not be most satisfactory answer but for me it literally just stopped ahppening out of the blue after a certain point. Maybe it takes time for Mapbox to get used to rendering all your features, i have no idea?

@sarath40158
Copy link

@maxmiranda

  • You can simple test this trying to load linePattern with LineLayer see code below
    Issue :
    On initial load at current zoom, Doesn't render any linePattern of LineLayer
    Once if we zoom In or Zoom Out it loads the linePattern image
RPReplay_Final1668421376.mov
 <MapboxGL.ShapeSource
      key={'ShapeSource'}
      id={'ShapeSource'}
      shape={{
        type: 'FeatureCollection',
        features: [
          {
            type: 'Feature',
            geometry: {
              type: 'LineString',
              coordinates: [
                [80.41956421171835, 16.29841309698017],
                [80.41956421171835, 16.29835131091197],
                [80.4195695761428, 16.29812476181567],
                [80.41966613564813, 16.29497879163125],
                [80.41966613564813, 16.294999387356782]
              ]
            }
          }
        ]
      }}>
      <MapboxGL.LineLayer
        key={'LineLayer'}
        id={'LineLayer'}
        sourceID={'ShapeSource'}
        style={{lineWidth: 8, linePattern: 
          'https://docs.mapbox.com/mapbox-gl-js/assets/colorado_flag.png'}}
        ></MapboxGL.LineLayer>
    </MapboxGL.ShapeSource>

@sarath40158
Copy link

Any one facing same issue I has temporary fix

File : RCTMGLStyle.m
replace : ==> linePattern Prop

From :

[RCTMGLUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] callback:^(NSError *error, UIImage *image) {
          if (image != nil) {
            dispatch_async(dispatch_get_main_queue(), ^{
              if (isValid()) {
                [self->_style setImage:image forName:imageURI];
                [self setLinePattern:layer withReactStyleValue:styleValue];
              }
            });
          }
        }];

To :

  NSString *imageURI = [styleValue getImageURI];
            NSURL *url = [NSURL URLWithString:imageURI];
            NSData *data = [NSData dataWithContentsOfURL:url];
            UIImage* img = [[UIImage alloc]initWithData:data];
            
            if (img != nil) {
                [self->_style setImage:img forName:imageURI];
                [self setLinePattern:layer withReactStyleValue:styleValue];
            }

If any one facing pattern issue with images running on main thread and RCTMGLUtils fetchImage had some issue in rendering the image on load

OdNairy added a commit that referenced this issue Apr 6, 2023
* Bump Snaphot and update some APIs

* Declare padding argument as an optional

* Changelog
mapbox-github-ci-writer-public-1 bot pushed a commit that referenced this issue Apr 13, 2023
* Bump Snaphot and update some APIs

* Declare padding argument as an optional

* Changelog
OdNairy added a commit that referenced this issue Aug 22, 2023
* Bump Snaphot and update some APIs

* Declare padding argument as an optional

* Changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something is broken!
Projects
None yet
Development

No branches or pull requests

4 participants