Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Markers flickering in/out #8367

Closed
yperess opened this issue Mar 12, 2017 · 9 comments
Closed

Markers flickering in/out #8367

yperess opened this issue Mar 12, 2017 · 9 comments
Labels
Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android bug

Comments

@yperess
Copy link

yperess commented Mar 12, 2017

Platform: Android
Mapbox SDK version:5.0.0. beta 2

Demo: video

Steps to trigger behavior

  1. Add several markers via addMarker(MarkerViewOptions)
  2. Override map rotation/zooming to manually alter the camera
  3. Move the camera around until markers begin clipping

Expected behavior

Markers that are in the visible region should remain visible

Actual behavior

Markers appear to be randomly being removed.

I traced this down to a specific region: invalidateMarkersInVisibleRegion

In here, getMarkerViewsInRect returns an incorrect list of marker views. I verified this by attaching a OnGlobalLayoutListener to the view and noticing that some times when I run:

boolean visible = mMapboxMap.getProjection()
        .getVisibleRegion()
        .latLngBounds
        .contains(markerView);
PointF screenPoint = mMapboxMap.getProjection()
        .toScreenLocation(markerView.getPosition());
boolean screenVisible = viewRectF.contains(screenPoint.x, screenPoint.y)
// visible != screenVisible

Unfortunately, even if I then override the view's visibility according to screenVisible (which seems to be more accurate) the marker still flickers out.

@jmkiley jmkiley added Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android bug labels Mar 13, 2017
@tobrun tobrun self-assigned this Mar 13, 2017
@tobrun
Copy link
Member

tobrun commented Mar 13, 2017

@yperess do you have some code to reproduce this with? Tried reproducing this with the test app MarkerView setup without any luck. Are you using anchoring/offset? Large icons?

@yperess
Copy link
Author

yperess commented Mar 13, 2017

@tobrun I'll try to get you a sample. Unfortunately our code is in a private repo right now and I can't just share it. I'll try to extract a sample tonight and post a link to it here. For now here's a very rough sample of what we're doing. The images coming in from the network are capped at around 100x100 px (depending on screen density)

final MarkerView marker = mMap.addMarker(new MarkerViewOptions()
        .flat(false)
        .position(new LatLng(pin.latitude, pin.longitude));
Picasso.with(getContext())
        .load(url)
        .into(new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                // Here I add some code that manipulates the bitmap by using a canvas and
                // adding multiple extra bits to it (such as a base that lays flat on the
                // map).
                marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(bitmap));
                marker.setAnchor(0.5f, baseOffsetRatio);
            }
            @Override
            public void onBitmapFailed(Drawable errorDrawable) {
            }
            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {
            }
        });

@tobrun
Copy link
Member

tobrun commented Mar 14, 2017

Haven't been able to reproduce the issue, would you be able to retest with the latest SNAPSHOT?
Since beta.2 the underlying code has changed a bit.

ezgif com-video-to-gif 14

ezgif com-video-to-gif 12

@yperess
Copy link
Author

yperess commented Mar 14, 2017 via email

@yperess
Copy link
Author

yperess commented Mar 15, 2017

https://github.com/yperess/MapboxClippingDemo

Notice that it takes me about 60+ seconds to find the right combination of zoom/orientation where the views get clipped

Video

@galacticappster04
Copy link

@tobrun, where is this add markers in bulk sample? How are you able to add multiple marker views (1000) on the map? I have markerviews a custom one and I just have 180+ markers and it was very slow.

@tobrun tobrun removed their assignment Apr 19, 2017
@tobrun
Copy link
Member

tobrun commented Apr 19, 2017

@neonwarge04 the system will keep inflating views if it needs to display a MarkerView. The key is to not show them all at once ( this will make the system recycle the views instead of inflating new ones).

Related to the issue, haven't seen any reports and underlying logic has changed.
Feel free to reach out if this is still an issue. Closing for now.

@tobrun tobrun closed this as completed Apr 19, 2017
@yperess
Copy link
Author

yperess commented Apr 19, 2017

It's a blocking issue which has left us with migrating off your product and over to Google Maps until this can be resolved. Did you have no luck with the sample app I provided?

@tobrun
Copy link
Member

tobrun commented Apr 24, 2017

Thank you for the additional ping, been looking a bit more in this issue and believe the source will be related to #8799. Thank again for reaching out and reporting your issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android annotations Annotations on iOS and macOS or markers on Android bug
Projects
None yet
Development

No branches or pull requests

4 participants