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

Remove black surface during map start up #12377

Merged
merged 1 commit into from
Jul 27, 2018
Merged

Remove black surface during map start up #12377

merged 1 commit into from
Jul 27, 2018

Conversation

tobrun
Copy link
Member

@tobrun tobrun commented Jul 12, 2018

Closes #10990, this PR exposes a color int configuration on MapboxMapOptions that is used as foreground color during map startup. Only when the style has loaded, we will show the render surface. This results in removing the black flash as shown in #10990.

ezgif com-resize 1

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Jul 12, 2018
@tobrun tobrun added this to the android-v6.4.0 milestone Jul 12, 2018
@tobrun tobrun self-assigned this Jul 12, 2018
@tobrun tobrun requested a review from LukasPaczos July 12, 2018 17:13
Copy link
Member Author

@tobrun tobrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really satisfied with current exposed naming of loadColor, looking for alternatives

edit: went with foregroundLoadColor instead.

@tobrun tobrun force-pushed the tvn-load-color branch 3 times, most recently from e418a99 to 97fdde8 Compare July 12, 2018 21:39
@tobrun tobrun force-pushed the tvn-load-color branch 3 times, most recently from 6eb9e10 to c681f0c Compare July 16, 2018 09:31
Copy link
Contributor

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@tobrun
Copy link
Member Author

tobrun commented Jul 18, 2018

Been trying out a couple of configurations (different map change events) to see if we can remove the black surface as seen on some lower end devices.

Hooking into MapView#DID_FINISH_RENDERING_FRAME_FULLY_RENDERED atm does seem to work reliably to hide the black surface.

@tobrun
Copy link
Member Author

tobrun commented Jul 19, 2018

@LukasPaczos would you be able to re-review? I took a different approach in 3dc0365


@Override
public void onMapChanged(int change) {
if (change == MapView.DID_FINISH_RENDERING_FRAME) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a typo here. As you mentioned, MapView#DID_FINISH_RENDERING_FRAME_FULLY_RENDERED works as expected, but MapView#DID_FINISH_RENDERING_FRAME doesn't resolve the issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to document my follow up findings:
I found that MapView#DID_FINISH_RENDERING_FRAME_FULLY_RENDERED was taking a long time to show the map to the end user. Before core emits that event we receive multiple MapView#DID_FINISH_RENDERING_FRAME with every render invocation we render a bit more content overtime. First time we render the black surface, second time we render the background (this is why there is a counter there). Feel free to play around this yourself but I feel this was providing a better UX.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check out the following setup in the MapboxMap#onStart that imitates bad connection:

void onStart() {
  nativeMapView.update();
  if (TextUtils.isEmpty(nativeMapView.getStyleUrl()) && TextUtils.isEmpty(nativeMapView.getStyleJson())) {
    // if user hasn't loaded a Style yet
    new Handler().postDelayed(() -> nativeMapView.setStyleUrl(Style.MAPBOX_STREETS), 2000L);
  }
}

Waiting for MapView#DID_FINISH_RENDERING_FRAME_FULLY_RENDERED here does the job well, but if you feel like it's too long, maybe you could wait for the style to load and then wait for those 2 frames to be partially rendered?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for testing and catching that use-case! I implemented the latter suggestion and I feel it's working great for normal usage as for this specific case. LMK what you think.

@tobrun tobrun force-pushed the tvn-load-color branch 4 times, most recently from f156605 to 3e48765 Compare July 26, 2018 10:03
Copy link
Contributor

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@tobrun tobrun merged commit 1be6310 into master Jul 27, 2018
@tobrun tobrun deleted the tvn-load-color branch July 27, 2018 09:40
@sictiru
Copy link

sictiru commented Oct 25, 2018

Can you do the same thing when the map gets destroyed ? I don't see the black screen on start up anymore but do every time when switching to the next fragments in a view pager.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants