How to stop GMSMapView renderer?












4















I noticed a performance issue when using GMSMapView as part of my view hierarchy. Important note: the map doesn't take up the whole screen, it is used as a table view header. These issues affect the behaviour of the table view itself - low FPS, which results in a bad user experience, so I'm trying to resolve these issues or at least understand what GMSMapView is doing.



Using Time Profiler I found out that this is cased by the GMSMapView re-rendering on every frame (as I can tell), because the heaviest stack trace on the main thread is:



enter image description here



Which is called from:
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION



(I guess it's just how internals of Google Maps work - it registers a CADisplayLink with a runloop and re-renders it on each frame)



This results in a heavy CPU usage (up to 99%):



enter image description here



Note that on the selected area nothing really happens to the app, it just displays a static map and a table view (no user interaction, no frame changes, no anything)



If I conduct the same test without a GMSMapView as a subview, the CPU usage in the same place is almost 0%:



enter image description here



Now to the question. Why is that happening and how to stop this behaviour?



I found a method called - (void) stopRendering on a GMSMapView, and tested it - the results are good and I get the same performance as when I completely remove the map view. However, this method is marked as deprecated and it states that it will be removed in a future releases of the SDK, which makes it a bad candidate for a long-term solution.



Any help, explanation or clues will be appreciated!










share|improve this question





























    4















    I noticed a performance issue when using GMSMapView as part of my view hierarchy. Important note: the map doesn't take up the whole screen, it is used as a table view header. These issues affect the behaviour of the table view itself - low FPS, which results in a bad user experience, so I'm trying to resolve these issues or at least understand what GMSMapView is doing.



    Using Time Profiler I found out that this is cased by the GMSMapView re-rendering on every frame (as I can tell), because the heaviest stack trace on the main thread is:



    enter image description here



    Which is called from:
    CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION



    (I guess it's just how internals of Google Maps work - it registers a CADisplayLink with a runloop and re-renders it on each frame)



    This results in a heavy CPU usage (up to 99%):



    enter image description here



    Note that on the selected area nothing really happens to the app, it just displays a static map and a table view (no user interaction, no frame changes, no anything)



    If I conduct the same test without a GMSMapView as a subview, the CPU usage in the same place is almost 0%:



    enter image description here



    Now to the question. Why is that happening and how to stop this behaviour?



    I found a method called - (void) stopRendering on a GMSMapView, and tested it - the results are good and I get the same performance as when I completely remove the map view. However, this method is marked as deprecated and it states that it will be removed in a future releases of the SDK, which makes it a bad candidate for a long-term solution.



    Any help, explanation or clues will be appreciated!










    share|improve this question



























      4












      4








      4


      2






      I noticed a performance issue when using GMSMapView as part of my view hierarchy. Important note: the map doesn't take up the whole screen, it is used as a table view header. These issues affect the behaviour of the table view itself - low FPS, which results in a bad user experience, so I'm trying to resolve these issues or at least understand what GMSMapView is doing.



      Using Time Profiler I found out that this is cased by the GMSMapView re-rendering on every frame (as I can tell), because the heaviest stack trace on the main thread is:



      enter image description here



      Which is called from:
      CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION



      (I guess it's just how internals of Google Maps work - it registers a CADisplayLink with a runloop and re-renders it on each frame)



      This results in a heavy CPU usage (up to 99%):



      enter image description here



      Note that on the selected area nothing really happens to the app, it just displays a static map and a table view (no user interaction, no frame changes, no anything)



      If I conduct the same test without a GMSMapView as a subview, the CPU usage in the same place is almost 0%:



      enter image description here



      Now to the question. Why is that happening and how to stop this behaviour?



      I found a method called - (void) stopRendering on a GMSMapView, and tested it - the results are good and I get the same performance as when I completely remove the map view. However, this method is marked as deprecated and it states that it will be removed in a future releases of the SDK, which makes it a bad candidate for a long-term solution.



      Any help, explanation or clues will be appreciated!










      share|improve this question
















      I noticed a performance issue when using GMSMapView as part of my view hierarchy. Important note: the map doesn't take up the whole screen, it is used as a table view header. These issues affect the behaviour of the table view itself - low FPS, which results in a bad user experience, so I'm trying to resolve these issues or at least understand what GMSMapView is doing.



      Using Time Profiler I found out that this is cased by the GMSMapView re-rendering on every frame (as I can tell), because the heaviest stack trace on the main thread is:



      enter image description here



      Which is called from:
      CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION



      (I guess it's just how internals of Google Maps work - it registers a CADisplayLink with a runloop and re-renders it on each frame)



      This results in a heavy CPU usage (up to 99%):



      enter image description here



      Note that on the selected area nothing really happens to the app, it just displays a static map and a table view (no user interaction, no frame changes, no anything)



      If I conduct the same test without a GMSMapView as a subview, the CPU usage in the same place is almost 0%:



      enter image description here



      Now to the question. Why is that happening and how to stop this behaviour?



      I found a method called - (void) stopRendering on a GMSMapView, and tested it - the results are good and I get the same performance as when I completely remove the map view. However, this method is marked as deprecated and it states that it will be removed in a future releases of the SDK, which makes it a bad candidate for a long-term solution.



      Any help, explanation or clues will be appreciated!







      ios google-maps google-maps-sdk-ios






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 3 '18 at 15:04







      markvasiv

















      asked Nov 24 '18 at 16:32









      markvasivmarkvasiv

      252113




      252113
























          1 Answer
          1






          active

          oldest

          votes


















          1





          +50









          The problem with stopRendering is that it places the burden of managing the map state on the developer.



          Instead of using stopRendering, you should limit the frame rate of the object. GMSMapView has a property called preferredFrameRate. You should be using that. It says in the documentation that by default preferredFrameRate is set to maximum, or to re-render every frame.



          preferredFrameRate is of an enum called GMSFrameRate. Which has values:




          1. kGMSFrameRatePowerSave

          2. kGMSFrameRateConservative

          3. kGMSFrameRateMaximum


          You should be using #2 to ensure that the map stays fluid during user interaction, but also doesnt render needlessly. By default preferredFrameRate is set to #3.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460181%2fhow-to-stop-gmsmapview-renderer%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1





            +50









            The problem with stopRendering is that it places the burden of managing the map state on the developer.



            Instead of using stopRendering, you should limit the frame rate of the object. GMSMapView has a property called preferredFrameRate. You should be using that. It says in the documentation that by default preferredFrameRate is set to maximum, or to re-render every frame.



            preferredFrameRate is of an enum called GMSFrameRate. Which has values:




            1. kGMSFrameRatePowerSave

            2. kGMSFrameRateConservative

            3. kGMSFrameRateMaximum


            You should be using #2 to ensure that the map stays fluid during user interaction, but also doesnt render needlessly. By default preferredFrameRate is set to #3.






            share|improve this answer






























              1





              +50









              The problem with stopRendering is that it places the burden of managing the map state on the developer.



              Instead of using stopRendering, you should limit the frame rate of the object. GMSMapView has a property called preferredFrameRate. You should be using that. It says in the documentation that by default preferredFrameRate is set to maximum, or to re-render every frame.



              preferredFrameRate is of an enum called GMSFrameRate. Which has values:




              1. kGMSFrameRatePowerSave

              2. kGMSFrameRateConservative

              3. kGMSFrameRateMaximum


              You should be using #2 to ensure that the map stays fluid during user interaction, but also doesnt render needlessly. By default preferredFrameRate is set to #3.






              share|improve this answer




























                1





                +50







                1





                +50



                1




                +50





                The problem with stopRendering is that it places the burden of managing the map state on the developer.



                Instead of using stopRendering, you should limit the frame rate of the object. GMSMapView has a property called preferredFrameRate. You should be using that. It says in the documentation that by default preferredFrameRate is set to maximum, or to re-render every frame.



                preferredFrameRate is of an enum called GMSFrameRate. Which has values:




                1. kGMSFrameRatePowerSave

                2. kGMSFrameRateConservative

                3. kGMSFrameRateMaximum


                You should be using #2 to ensure that the map stays fluid during user interaction, but also doesnt render needlessly. By default preferredFrameRate is set to #3.






                share|improve this answer















                The problem with stopRendering is that it places the burden of managing the map state on the developer.



                Instead of using stopRendering, you should limit the frame rate of the object. GMSMapView has a property called preferredFrameRate. You should be using that. It says in the documentation that by default preferredFrameRate is set to maximum, or to re-render every frame.



                preferredFrameRate is of an enum called GMSFrameRate. Which has values:




                1. kGMSFrameRatePowerSave

                2. kGMSFrameRateConservative

                3. kGMSFrameRateMaximum


                You should be using #2 to ensure that the map stays fluid during user interaction, but also doesnt render needlessly. By default preferredFrameRate is set to #3.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 10 '18 at 14:50

























                answered Dec 10 '18 at 14:41









                DylanDylan

                404113




                404113
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460181%2fhow-to-stop-gmsmapview-renderer%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Futebolista

                    Feedback on college project

                    Albești (Vaslui)