Closed Bug 1541518 Opened 5 years ago Closed 5 years ago

Fenix startup spends 226ms on "getScreenDepth"

Categories

(Core :: Performance, defect, P1)

67 Branch
Unspecified
Android
defect

Tracking

()

RESOLVED INVALID
Tracking Status
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- affected

People

(Reporter: sphilp, Assigned: whawkins)

References

(Blocks 1 open bug)

Details

(Whiteboard: [geckoview:fenix:m7])

According to Nimbledroid's icicle chart on the cold startup test, Fenix (when compared to Geckoview Example) is spending 226ms on GeckoAppShell.getScreenDepth, which seems to be

https://searchfox.org/mozilla-central/source/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java#1052

Seems like a long time given the definition above

Thank you, sphilp, for filing this. I've seen this before, too. I will take ownership of this unless there are objections?

Flags: needinfo?(sphilp)

It's under our component Core:Performance so yes, free to take. Thank you!

Assignee: nobody → whawkins
Flags: needinfo?(sphilp)

Adding [geckoview:fenix:m5] whiteboard tag to track this issue for Fenix MVP.

OS: Unspecified → Android
Whiteboard: [geckoview:fenix:m5]

Will, is this bug assigned to you because you're going to fix it or just because you are still profiling startup problems? Do I need to find a GeckoView Android engineer to fix this?

Flags: needinfo?(whawkins)
Priority: -- → P1

Interesting that you wrote this when you did. I was just about to provide an update:

This does not appear to be the source of any performance problem for the startup of Fenix. In this particular case, the function is called from the constructor of the gfxAndroidPlatform which is called from gfxPlatform::Init() the first time that the platform is required. Again, in this particular case, that happens when the main "browser" starts as a GeckoThread. The UI does not block waiting for the completion of the initialization of this Thread and, therefore, there are no noticeable affects.

In order to prove to myself that this was the case, I made the getScreenDepth() function return a constant value. It's runtime no longer showed up in the nimbledroid (ND) profile, but (non-intuitively) the startup time increased. Note: This is an artifact of the test platform. If you're interested in my current hypothesis about why this happens, I'll be happy to tell you offline.

One final note. This comes with the caveat that all of this is information provided with the best of my knowledge.

There is a way to optimize this function, if we want. We can easily remove the call to the Android SDK entirely as long as we are comfortable targeting devices that are platform level > 17. In that revision of the platform SDK, "This method is no longer supported. The result is always PixelFormat#RGBA_8888." As a result, we can simply set sScreenDepth to 32 and be happy.

I would enjoy the opportunity to talk to GV engineer about this to make sure that my understanding and description are accurate. In fact, that would be a good idea. Is there someone that I should reach out to?

I hope that this investigation helps!
Will

Flags: needinfo?(whawkins) → needinfo?(cpeterson)

We can easily remove the call to the Android SDK entirely as long as we are comfortable targeting devices that are platform level > 17.

Good news! GeckoView requires API Level >= 18 so we can make that change for GeckoView (but not Fennec, because it requires API level >= 16).

we can simply set sScreenDepth to 32 and be happy.

If sScreenDepth is hard-coded to 32, then we might be able to remove GeckoAppShell.getScreenDepth() and simplify many of the callers of GeckoAppShell.getScreenDepth() and AndroidBridge::GetScreenDepth() by propagating the constant 32 into C++. Some callers have special cases to handle 16 or 24 bit screen depths.

I would enjoy the opportunity to talk to GV engineer about this to make sure that my understanding and description are accurate. In fact, that would be a good idea. Is there someone that I should reach out to?

Pinging @snorp or @rbarker in the #gv Slack channel would probably be a good place to start. If you would prefer a face-to-face meeting, just let me know and I can invite you to our next GV engineering team meeting.

Flags: needinfo?(cpeterson)

I was going to reply to the comment above inline, but my mobile browser does not seem to like that. Overall, I agree with your suggestion but will write more first thing tomorrow. Thanks for the feedback!

Will

Adding [geckoview:fenix:m7] whiteboard tag because this bug is important but not strictly a Fenix MVP release blocker.

Whiteboard: [geckoview:fenix:m5] → [geckoview:fenix:m7]

(In reply to Will Hawkins from comment #7)

I would enjoy the opportunity to talk to GV engineer about this to make sure that my understanding and description are accurate. In fact, that would be a good idea. Is there someone that I should reach out to?

Your understanding seems accurate in that activity on the Gecko thread should generally not stop the UI. However, long startup operations on the Gecko thread do block us from rendering the first page, so we might still care about these problems.

Status: NEW → ASSIGNED

It turns out that I cannot reproduce this on a Pixel 2 or Motorola g5 device. Even without the optimization in place, the function takes less than (at most) 5ms.

I am attempting to reproduce this on the Nexus 5 with older Android platform -- the setup that mimics ND.

We confirmed with ND that their profiler mistimes this function -- it does not take this amount of time. There are ways to optimize this function (as described above) but there is no reason to do those optimizations at this time.

Closing.

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.