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

MGLMapView turns black when returning from another UIViewController. #1003

Closed
mb12 opened this issue Mar 14, 2015 · 14 comments
Closed

MGLMapView turns black when returning from another UIViewController. #1003

mb12 opened this issue Mar 14, 2015 · 14 comments
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS
Milestone

Comments

@mb12
Copy link

mb12 commented Mar 14, 2015

This consistently reproduces. Here is how to reproduce it.

  1. From the UIViewController that hold MGLMapView push a new UIViewController
  2. Tap Back

Screen is black after tapping back.

This is what I have tried to figure out the root cause so far. Please note #2 (Issue disappears when breakpoint inserted inside asyncRender callback function).

1.) I tried forcing rerender via Map::update from viewWillAppear (UIThread) but it does not seem to help.
2.) If I put breakpoint inside asyncRender to debug whether the render is actually happening, the issue disappears.

@robipresotto
Copy link

+1

@incanus incanus added bug iOS Mapbox Maps SDK for iOS labels Mar 14, 2015
@incanus incanus added this to the iOS Beta 1 milestone Mar 14, 2015
@incanus
Copy link
Contributor

incanus commented Mar 14, 2015

@kkaefer Do you think this might be related to your recent missing frame fix?

@mb12 @robipresotto Can you see if the situation changes without 47ede85, which fixed the above issue recently?

@mb12
Copy link
Author

mb12 commented Mar 14, 2015

@incanus Forcing rerender via Map::update from UIViewController::viewDidAppear addresses the issue. I will keep an eye on it and let you know if the issue reappears with this change. I think this also explains why putting breakpoint in asyncRender was causing the issue to disappear.

When I had it in viewWillAppear, it wasn't helping until I put a breakpoint in asyncRender. Putting breakPoint in asyncRender was probably forcing render to happen after viewDidAppear.

@robipresotto
Copy link

[[MGLMapView alloc] initWithFrame: styleJSON: accessToken:];

I receive this error when the user go out of the app and back to the app,
[ERROR] Setup: (-1) loading style failed: The operation couldn’t be completed. (NSURLErrorDomain error -1002.)

The error turns the map view black in my case

ideas?

@robipresotto
Copy link

The StyleURL from this method is empty when you close the app and re-open the app (or push the mapviewcontroller from another view)...

void Map::prepare() {
assert(std::this_thread::get_id() == mapThread);

if (!style) {
    style = std::make_shared<Style>();

    env->request({ Resource::Kind::JSON, styleURL}, [&](const Response &res) {
        if (res.status == Response::Successful) {
            // Calculate the base
            const size_t pos = styleURL.rfind('/');
            std::string base = "";
            if (pos != std::string::npos) {
                base = styleURL.substr(0, pos + 1);
            }

            setStyleJSON(res.data, base);
        } else {
            Log::Error(Event::Setup, "loading style failed: %s", res.message.c_str());
            std::cout << "styleURL " << styleURL;
        }
    });
}

@robipresotto
Copy link

@mb12 how are you updating the map from uiviewcontroller? for me still the same problem...

@incanus
Copy link
Contributor

incanus commented Mar 20, 2015

@mb12 @robipresotto How is this looking to you currently on master?

@mb12
Copy link
Author

mb12 commented Mar 20, 2015

I think the issue that I've reported and the one @robipresotto is referring to are different issues.
I can try the latest master tomorrow morning or on Monday but I don't think the issue is fixed since its related to UIViewController lifecycle.

1.) From MBXViewController, push/present an new UIViewController.
2.) Tap on "Back".

The MapScreen turns black unless touched / re-rendered. I am able to work around it by forcing re-render from viewDidAppear.

@robipresotto
Copy link

okay, can be! i can open a new issue.

@1ec5
Copy link
Contributor

1ec5 commented Mar 27, 2015

Doesn’t currently seem to reproduce with push or show segues in storyboards. Let’s see if it reproduces programmatically…

@1ec5
Copy link
Contributor

1ec5 commented Mar 30, 2015

@mb12, I still can’t reproduce the issue on master (iOS 8.3 iPhone 6 Simulator, iOS 8.2 iPhone 5 Simulator, iOS 8.2 iPhone 6):

push

Can you share the code you’re working with?

@mb12
Copy link
Author

mb12 commented Mar 30, 2015

Sorry I misunderstood your question.
The only difference is that I've everything inside a UINavigationController.

  1. MBXViewController is the root controller in the navigation UINavigationController stack.

I've updated to the latest repo. Let me try by commenting the call to triggerUpdate in viewDidAppear.

@mb12
Copy link
Author

mb12 commented Mar 30, 2015

This bug is fixed in the latest repo. Latest MGLMapView uses drawInRect to call renderSync from drawInRect:.
I've an old repo where the bug reproduces because renderSync in missing from drawInRect:.

Thank you very much for following up on this and fixing it properly.

@1ec5
Copy link
Contributor

1ec5 commented Mar 30, 2015

Glad to hear it’s working now!

@1ec5 1ec5 closed this as completed Mar 30, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

4 participants