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

[ios] Ensure renderer is flushed when going into the background. - #14222

Closed
julianrex wants to merge 10 commits into
masterfrom
jrex/display-link-rendering-updates
Closed

julianrex wants to merge 10 commits into
masterfrom
jrex/display-link-rendering-updates

Conversation

@julianrex

@julianrex julianrex commented Mar 25, 2019 •

Copy link
Copy Markdown
Contributor

We have a number of crashes that appear to be related to rendering in the background: #13821, #13824, #13825 - which is counter to Apple's recommendations.

Looking at this comment from 13821, it was determined that it's possible to put the app into a state where MGLMapView isn't dormant and GL rendering can occur. (This is probably in situations where the map view is created programmatically, or some other view controller is affecting the view hierarchy when backgrounding).

PR #14156 introduces mbgl::Renderer::flush() which allows us to ensure glFinish() is called when going into the background as recommended.

This PR adds:

  • An integration test to exercise the bug described (manipulating views - essentially remove and re-add).
  • Some reorganization of how the display link is managed.
  • A private MGLApplication protocol to aid with mocking.
  • Flushing the renderer when backgrounding.
  • A bug fix in -glkView:drawInRect:

Changes:

  • Pauses the display link upon receiving UIApplicationWillResignActiveNotification - this needs some discussion as this is a change in behavior.

TODO?

  • Refactor validateDisplayLink - because of the situation above, it's possible to have a nil or non-nil display link when entering the background. I propose that we should only pause/unpause the display link - and perhaps be more explicit.
  • Test launch conditions, to investigate this Firebase comment. Propose we add this in a follow up PR, though this may be a SEMVER major change.
  • Check how this affects external devices (AppleTV, CarPlay)
  • Change log

cc @tmpsantos @chloekraw

@julianrex
julianrex requested review from friedbunny and jmkiley March 25, 2019 13:58
@julianrex julianrex added iOS Mapbox Maps SDK for iOS rendering labels Mar 25, 2019
@julianrex
julianrex force-pushed the jrex/display-link-rendering-updates branch from 20038c1 to 0788343 Compare April 4, 2019 20:08
@chloekraw

Copy link
Copy Markdown
Contributor

cc/ @kkaefer

@julianrex julianrex self-assigned this Apr 8, 2019
@julianrex

Copy link
Copy Markdown
Contributor Author

For reference this PR is somewhat stale, now that some changes have landed in master. I'll be updating shortly, but the gist of the PR is still valid.

@julianrex
julianrex force-pushed the jrex/display-link-rendering-updates branch from 0788343 to 70603dc Compare April 16, 2019 15:43
@julianrex

Copy link
Copy Markdown
Contributor Author

Noting here that an intermediate PR (#14439) has landed on master and on release-liquid that addresses the symptoms, whereas this PR is about fixing addressing the probable root cause.

@julianrex

Copy link
Copy Markdown
Contributor Author

4.10.0 was released with #14439.

@pappalar

Copy link
Copy Markdown

@julianrex I have a displayLink crash like the other reported here. we might open a new issue with the stack trace, but I wanted to give some details as this PR is working on the renderer and I think the issue is not only in background.

I get the same crash when I pop from the stack the view controller that is displaying the map.
It only happens if I close the view controller immediately after it appears.
My impression is that the renderer is having a memory leak and keeps a reference to the mapView.

So my controller gets destroyed, and the updateDisplayLink is called to the mapView that is actually already gone.

@julianrex

Copy link
Copy Markdown
Contributor Author

@racer1988 thanks for this insight! This PR is currently undergoing some refactoring due to recent changes in core, and we'll make sure to consider this scenario.

What version of the SDK are you currently on? It would be interesting to know if you still see issues with a more recent SDK if that's applicable.

@pappalar

pappalar commented Jun 14, 2019 •

Copy link
Copy Markdown

Currently on
pod 'Mapbox-iOS-SDK', '~> 5.0.0'

EDIT: This issue is very easily reproducible in a simulator.
It's seems to be way harder to reproduce on the device.

My supposition for that is that the renderer on the device is using the GPU so it's fast.
the simulator uses CPU for all the processes, so it kicks in too late

@friedbunny friedbunny removed this from the release-oolong milestone Jun 28, 2019
@stale stale Bot added the archived Archived because of inactivity label Aug 27, 2019
@stale

stale Bot commented Aug 28, 2019

Copy link
Copy Markdown

This pull request has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale Bot closed this Aug 28, 2019
@chloekraw chloekraw removed the archived Archived because of inactivity label Aug 28, 2019
@chloekraw chloekraw reopened this Aug 28, 2019
@friedbunny
friedbunny removed their request for review October 23, 2019 20:54
@stale stale Bot added the archived Archived because of inactivity label Mar 17, 2020
@stale

stale Bot commented Mar 17, 2020

Copy link
Copy Markdown

This pull request has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

archived Archived because of inactivity iOS Mapbox Maps SDK for iOS rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants