‹ BackHN Continuity

Thread

GrapheneOS – When an app is slow

86 points · 64 comments · speckx

Loading the complete thread in the background. This saved snapshot is available now. Refresh

  1. perching_aix · · focus · HN ↗
    If you have two apps, both maps...

    > The reason behind it is the hardened memory allocator, which seems to create a significant overhead for Osmand. That might be because scrolling a map requires constant loading and discarding of data.

    ... is this really the right hunch, over e.g. the OpenStreetMaps app lacking in discipline with its heap allocations?

    1. himata4113 · · focus · HN ↗
      Seems unlikely, it's java so this is likely related to loading large amounts of objects and having the GC thrashing.
      1. RedComet · · focus · HN ↗
        The core is C++ afaik.
        1. grapheneos · · focus · HN ↗
          OsmAnd has a large legacy C++ codebase with a lot of memory corruption bugs. Many memory corruption bugs have been found and reported by GrapheneOS users. It isn't yet clear if the performance issues the OpenGL renderer has with hardened_malloc are caused by it making too many allocations or actual bugs.

          The hardened_malloc configuration used by GrapheneOS is very security-oriented including using a quarantine for freed slab allocations and it could provide a toggle to use a more performance-oriented configuration for an app instead of only being able to use the default allocator instead.

      2. someonebaggy · · focus · HN ↗
        C++ memory allocator choice probably wouldn't affect Java code, which has its own heap algorithms.
        1. cnrcode · · focus · HN ↗

          [dead]

          1. grapheneos · · focus · HN ↗
            The hardened allocator doesn't wrap malloc but rather is the default malloc implementation on GrapheneOS with a per-app opt-out toggle. It makes no substantial difference for overall OS performance but there are definitely apps where it matters. OsmAnd works fine for most users without disabling it though.
    2. grapheneos · · focus · HN ↗
      It's very likely caused by a set of bugs in the app rather than simply inefficient patterns. Users regularly report hardened_malloc detecting memory corruption bugs in OsmAnd.
  2. pjmlp · · focus · HN ↗
    Maybe the actual solution is to improve, replace the application.
    1. mohamedkoubaa · · focus · HN ↗
      There needs to be a wall of shame for apps that abuse hardware owned by users
      1. yjftsjthsd-h · · focus · HN ↗
        How's it abusing anything? It's an Android app that works fine with the default Android memory allocator.
        1. perching_aix · · focus · HN ↗
          That doesn't necessarily mean it isn't being abusive, just that said allocator tolerates it okay.
        2. pjmlp · · focus · HN ↗
          The AOSP memory allocator is seldom the one used by OEMs.
          1. rpdillon · · focus · HN ↗
            Really? They're not using Scudo? The hardened_malloc used in GrapheneOS has a bunch of performance issues that were trade-offs against security. Every other major android distribution uses scudo as far as I know. Which OEMs are you thinking of?

            Edit: Did some research after writing this? It appears that Samsung may be still using jemalloc, albeit a newer version than the one from the Android 11 days.

            1. grapheneos · · focus · HN ↗
              No, it does not have "a bunch of performance issues". It has carefully considered performance vs. security compromises which are largely configurable. GrapheneOS uses hardened_malloc in a very security-oriented configuration and has the option to disable it per-app if there's ever a compatibility or performance issue. GrapheneOS could also offer another toggle for setting it to a performance mode where it isn't significantly slower than Scudo either via dynamic configuration or a 2nd build of hardened_malloc with a lighter configuration. Most overhead is from slab allocation quarantines which are optional.
              1. rpdillon · · focus · HN ↗
                Yikes, didn't mean to trigger any defensiveness. Can't edit my comment, but mentally replace "bunch of performance issues" with what you said: "performance vs. security compromises".
    2. izacus · · focus · HN ↗
      Or maybe there's a reason why the mainline Android OEMs don't ship that allocator by default.
      1. Groxx · · focus · HN ↗
        The fairly obvious answer here is "OEMs don't care about security because very few people will pay for it, either with $ or time". Benchmaxxing sells better.
        1. izacus · · focus · HN ↗
          That's trivially provable as false.
          1. nvme0n1p1 · · focus · HN ↗
            If so, I'd love to know which OEM you're thinking of who ships an Android distro more secure than GrapheneOS.
            1. izacus · · focus · HN ↗
              Let's first start with y'all providing any proof that it was "benchmaxxing" that causes OEMs not to ship hardened allocators (and not - for example - breaking compatibility with users' software).

              And then we can move the goalposts to "more secure distro with GrapheneOS" which isn't part of the conversation until you dragged it out.

              1. nvme0n1p1 · · focus · HN ↗
                If you're expecting some leaked internal document that says "priorities: 1. benchmarks, 2. security", no, that probably doesn't exist. But their priorities are revealed by their actions.

                GrapheneOS typically ships security updates within a day. But most of Samsung's phones get quarterly security updates[1]. There will never be a primary source with a Samsung insider saying "we're fine with our customers being vulnerable to widely exploited security bugs for 89 days, in order to save our massive corporation a few thousand dollars a month." But their priorities are revealed by their actions.

                If the statements "OEMs don't care about security" is trivially proven false, as you said, then you should be able to prove it trivially by naming even just a single OEM whose update cadence matches GrapheneOS's.

                [1]: <a href="https:&#x2F;&#x2F;security.samsungmobile.com&#x2F;workScope.smsb" rel="nofollow">https:&#x2F;&#x2F;security.samsungmobile.com&#x2F;workScope.smsb

                1. Groxx · · focus · HN ↗
                  Also look at their advertising. Endless &quot;X% faster&quot; mentions that often get significant visual space, but when was the last time you saw &quot;security updates 7 days earlier&quot; or &quot;tagged memory for better safety&quot;? Even a single mention of &quot;security&quot; on a phone&#x27;s manufacturer page is uncommon, and that&#x27;s usually just mentioning a normal Android feature, or something like Knox or Secure Folder and not &quot;we made choices that make a common class of attacks much more difficult or impossible&quot;.

                  The numbers aren&#x27;t zero, certainly. But they are incredibly obviously given wholly different levels of attention.

                  1. izacus · · focus · HN ↗
                    There isn&#x27;t a single phone and OS release that wouldn&#x27;t have a security improvements section: <a href="https:&#x2F;&#x2F;blog.google&#x2F;products-and-platforms&#x2F;platforms&#x2F;android&#x2F;android-17-features&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.google&#x2F;products-and-platforms&#x2F;platforms&#x2F;android...

                    (I&#x27;ll let you find the others yourself.)

                    How did you think Pixels got features GrapheneOS needs if the OEM wouldn&#x27;t care about adding the Titan chip, modem APIs and all the other security features that are featured on pretty much every launch doc?

                    Cut the crap already.

                    1. Groxx · · focus · HN ↗
                      Then let&#x27;s just take a random flagship device: <a href="https:&#x2F;&#x2F;www.samsung.com&#x2F;us&#x2F;smartphones&#x2F;galaxy-s26&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.samsung.com&#x2F;us&#x2F;smartphones&#x2F;galaxy-s26&#x2F;

                      The only &quot;secure&quot; stuff I see in there is for local AI stuff, encrypted folders, and securely managing other devices. Nothing at all about hardware security or updates or anything that Google has been adding to Android (which imo they&#x27;re fair to claim! but nearly none do).

                      iPhones are similar: <a href="https:&#x2F;&#x2F;www.apple.com&#x2F;iphone-18-pro&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.apple.com&#x2F;iphone-18-pro&#x2F; they have a small card to see Apple&#x27;s general privacy policy near the bottom, but other mentions are stuff on the level of &quot;it supports WiFi with passwords&quot;.

                      While there&#x27;s tons about AI, cameras, and speed. Because those sell better.

                      Which is far beyond &quot;a trend&quot; and approaching &quot;a truism&quot; for phone sales pages. I challenge you to show even a single large-market-share phone sales page that makes a device security claim (niche ones do! but they&#x27;re niche). The very first one I visited demonstrated my point just fine, as did the second.

                      Pixels actually do make some claims (&quot;7 years of updates&quot;, Titan chip, etc <a href="https:&#x2F;&#x2F;store.google.com&#x2F;product&#x2F;pixel_11_pro?hl=en-US" rel="nofollow">https:&#x2F;&#x2F;store.google.com&#x2F;product&#x2F;pixel_11_pro?hl=en-US) and Graphene routinely holds them up as the sole manufacturer doing a good job (now hopefully two manufacturers, for at least some products).

                    2. nvme0n1p1 · · focus · HN ↗
                      The android blog isn&#x27;t relevant here.

                      OEM = original equipment manufacturer

                      equipment = the phone you physically hold in your hand

                      The OS is software, not hardware. The OS vendor is not the OEM.

                      Yes, Android does a lot of security work. No, it doesn&#x27;t automatically mean Samsung cares about security, just because one of Samsung&#x27;s many dependencies cares about security.

              2. pessimizer · · focus · HN ↗
                &gt; Let&#x27;s first start with y&#x27;all providing any proof

                Your trivially proving things can&#x27;t involve asking other people to prove the opposite of things. You&#x27;ve instantly backed down.

                &gt; And then we can move the goalposts

                Why? You haven&#x27;t done anything except ask others to do things. You&#x27;ve moved the goalposts from trivially falsifiable, and started begging.

                1. izacus · · focus · HN ↗
                  I&#x27;m not going to play a game where you make up false shit and I do the work of disproving it while you move the goalposts with new false shit.
      2. pjmlp · · focus · HN ↗
        Because they cut costs on hardware and not all ship MTE enabled ARMs.
      3. palata · · focus · HN ↗
        Maybe... legacy?
      4. grapheneos · · focus · HN ↗
        The hardened_malloc project has performance vs. security configuration. It&#x27;s used in a very security-oriented configuration in GrapheneOS. GrapheneOS could offer a performance vs. security toggle for this but hasn&#x27;t yet included one since there are rarely apps with any noticeable performance difference. Android apps are mostly written in Java&#x2F;Kotlin where it makes no difference. There are often specific uses of optimized C, C++ or Rust code where it makes little difference. It&#x27;s rare for an app to be heavily impacted by malloc performance as if it&#x27;s a malloc microbenchmark, and even in that case the overhead is typically quite reasonable. OsmAnd is doing something very strange in a certain configuration.
  3. negative_zero · · focus · HN ↗
    Odd. Google Pixel 7 with GrapheneOS here. OsmAnd works perfectly fine for me without disabling any exploit protection options.
    1. BlackRabbit1 · · focus · HN ↗
      CoMaps behaves very very weirdly on GrapheneOS. Same with OrganicMaps.

      Osmand and GMaps are working fine.

      Waze is almost melting the poor thing. Beside of that working fine.

      1. ThePowerOfFuet · · focus · HN ↗
        I use Comaps daily on GrapheneOS on a Pixel 8 Pro and it works great.
      2. broodbucket · · focus · HN ↗
        Waze works perfectly fine for me
        1. DuncanCoffee · · focus · HN ↗
          Anyone writing about apps compatibility should specify if it&#x27;s with or without the play services
          1. DaSHacka · · focus · HN ↗
            Can you even run Waze&#x2F;GMaps without Play services?
            1. worldsavior · · focus · HN ↗
              Yes.
              1. Shared404 · · focus · HN ↗
                For more precision:

                Waze is fairly easy to run without play services. GMaps I haven&#x27;t yet found a way to run, but also haven&#x27;t looked in quite some time.

                1. grapheneos · · focus · HN ↗
                  Google Maps used to work without it but recently gained a hard dependency on Play services. We could add more shims to make more apps work without it installed but that hasn&#x27;t been a focus yet.
                  1. Shared404 · · focus · HN ↗
                    Makes sense. Any idea if there&#x27;s any interest in a shim to get notifications working sans Play services?

                    I haven&#x27;t looked at anything shim related in quite a while and am not super familiar with the notification stack for Android, so if that&#x27;s a stupid question I apologize.

              2. DaSHacka · · focus · HN ↗
                Neat, every day I inch closer to not needing Play Services anymore.

                <a href="https:&#x2F;&#x2F;plexus.techlore.tech&#x2F;apps?q=waze" rel="nofollow">https:&#x2F;&#x2F;plexus.techlore.tech&#x2F;apps?q=waze

            2. Nux · · focus · HN ↗
              Waze and Here Maps work well.
      3. subscribed · · focus · HN ↗
        Osmand and OrganicMaps work flawlessly for me. Waze on 6 (not pro), works better than on my 9 Pro.
      4. pizzaiolo · · focus · HN ↗
        Weirdly how? CoMaps seemingly works fine out of the box on my device
      5. gunalx · · focus · HN ↗
        Have had no noticable problems with organic maps.
      6. methuselah_in · · focus · HN ↗
        comaps and organic maps shares some of the same codebase right?
        1. archturtle · · focus · HN ↗
          AFAIK CoMaps is a fork of OrganicMaps after OrganicMaps added some sort of ads or sponsoring. They both use OSM
      7. grapheneos · · focus · HN ↗
        CoMaps and Waze definitely work well on GrapheneOS.
    2. Self-Perfection · · focus · HN ↗
      And yet problems exist. Live Updates are not rendered if both OsmAnd V2 rendering and hardened memory allocator are enabled: <a href="https:&#x2F;&#x2F;github.com&#x2F;osmandapp&#x2F;OsmAnd&#x2F;issues&#x2F;20190" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;osmandapp&#x2F;OsmAnd&#x2F;issues&#x2F;20190
      1. [deleted] · · focus · HN ↗

        [deleted]

      2. grapheneos · · focus · HN ↗
        Those are memory corruption bugs which are potentially exploitable vulnerabilities. There are no false positives for the security protections in hardened_malloc including the hardware memory tagging (MTE) integration. It only detects invalid memory corruptions via use-after-free or out-of-bounds accesses. Due to a relatively high number of apps having invalid memory accesses during regular use, we don&#x27;t enable MTE for all user installed apps yet. We always use MTE for the kernel and userspace code in the base OS but it&#x27;s opt-in for most user installed apps via a global toggle to enable it by default and a per-app toggle mainly intended for opting out for incompatible apps.

        OsmAnd has a massive amount of legacy C++ code which hasn&#x27;t been heavily tested with HWASan and MTE. It has a history of having many memory corruption bugs discovered and reported by GrapheneOS users. That&#x27;s the exploit protections in GrapheneOS working as intended and it&#x27;s why there are per-app compatibility toggles to work around apps which can&#x27;t be used due to memory corruption during regular use. It would be better if apps had higher quality native code and didn&#x27;t need us to provide compatibility toggles but that&#x27;s the way things are. It&#x27;s much worse on desktop operating systems.

  4. Groxx · · focus · HN ↗
    [delayed]
    1. WalterGR · · focus · HN ↗
      [delayed]
      1. Groxx · · focus · HN ↗
        [delayed]
    2. grapheneos · · focus · HN ↗
      It ends up acting as a malloc microbenchmark in certain configurations. It appears that it only happens when using the OpenGL renderer. GrapheneOS can provide a performance vs. security toggle for hardened_malloc for these rare cases but it hasn&#x27;t come up much.
  5. hadi77ir · · focus · HN ↗
    I wonder if a website using leaflet.js has better or worse performance in the said case. If it does better, then maybe the problem is on OsmAnd&#x27;s side?
    1. speedstyle · · focus · HN ↗
      Leaflet is (generally) for streaming image tiles, OsmAnd renders a list of features in realtime. But yes, it could do so more efficiently
  6. RKearney · · focus · HN ↗
    &quot;Before installing, please turn off all anti-virus and firewall software.&quot;
    1. grapheneos · · focus · HN ↗
      The feature protects the app from exploits and doesn&#x27;t provide any additional security for the OS from the app. It&#x27;s worth noting most users are having no issues running OsmAnd with hardened_malloc.
  7. hajjamixcv2012 · · focus · HN ↗

    [dead]

  8. aucisson_masque · · focus · HN ↗
    What is the point of this hardening feature if you got to disable it ?

    You can tweak Android as much as you want, the OS was not made to be private nor secure. App developers will never check if it breaks the grapheneos memory allocating feature (amongst others) so by default you disable it.

    Anyway it also requires the app to be able to even run on a rom that doesn’t respect play integrity.

    1. progval · · focus · HN ↗
      It&#x27;s meant to protect apps against their own bugs. It&#x27;s an improvement to be enabled by default and disabled for the few apps where it&#x27;s an issue.
    2. epihelix · · focus · HN ↗
      &gt; Anyway it also requires the app to be able to even run on a rom that doesn’t respect play integrity.

      ?? GrapheneOS does respect horrid play integrity (it provides basic integrity only).

      Not that this has any bearing on how an app runs performance-wise.

      1. aucisson_masque · · focus · HN ↗
        Before looking at how an app run “performance wise”, you got to be able to run it. That’s my point.

        Basic play integrity doesn’t mean much, more and more applications are requiring full play service integrity.

        1. grapheneos · · focus · HN ↗
          Very few apps require Play Integrity levels and a growing number of those are explicitly permitting GrapheneOS.
          1. aucisson_masque · · focus · HN ↗
            That’s not the trend I’m seeing with my pixel 9. More and more apps require it.

            You just need one app, that you really like and that doesn’t run on grapheneos to make a user leave.

    3. grapheneos · · focus · HN ↗
      &gt; What is the point of this hardening feature if you got to disable it ?

      It doesn&#x27;t have to be disabled. Most users are saying OsmAnd runs fine for them with the default of hardened_malloc being enabled. There was no need to disable the other hardening features. A subset of users are experiencing slow performance in the OpenGL rendering mode with hardened_malloc enabled. It&#x27;s likely due to the implementation in the app doing something quite inefficient which hasn&#x27;t yet been identified. The hardened_malloc configuration in GrapheneOS is heavily oriented to security and has more overhead than the lite configuration. We could offer a performance vs. security mode for it but it usually makes no major difference and has a toggle for any case it does.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.