Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.32k stars 2.76k forks source link

Add Profiling to mobile web debug options #46812

Closed puneetlath closed 1 day ago

puneetlath commented 1 month ago

Problem

On our mobile apps, we have the Use profiling option for performance profiling. We don't have this on web because profiling can be done via the JS console. However, mobile web doesn't have a JS console, so it'd be useful to be able to have some way to do profiling there. Recently, we've had an employee experiencing performance issues specifically on mobile web.

Solution

Add the Use profiling option to mobile web.

cc @Szymon20000

IMG_53B5C847EEAD-1

Szymon20000 commented 1 month ago

👋🏻

melvin-bot[bot] commented 1 month ago

Current assignee @puneetlath is eligible for the NewFeature assigner, not assigning anyone new.

kirillzyusko commented 1 month ago

Hey 👋 I think I added this option on web in https://github.com/Expensify/App/pull/46133? It could be activated via Cmd+K combination, though yeah, I'm not sure how to show that menu on mobile web 😅

hannojg commented 1 month ago

On mobile we have the 4-finger tap gesture to open that menu (implemented using RNGH), would the same work for mWeb @kirillzyusko ?

kirillzyusko commented 1 month ago

Thanks @hannojg ! ❤️

I just tested and this indeed works:

telegram-cloud-photo-size-2-5300879088497584250-y

File sample:

Profile_trace_for_9.0.17-0.cpuprofile

But keep in mind that not all browsers support "sampling profiling", so not all browsers will produce an actual stacktrace (I tested in Safari and it didn't work, the downloaded file was empty). To see which browsers support that you can check this link 👀

The file above was captured in Android Google Chrome broswer.

kirillzyusko commented 1 week ago

@puneetlath @muttmuure since it was deployed to staging - can we verify that it actually works there and close the issue?

puneetlath commented 1 week ago

I do see the option. This was on iOS Safari. Do we need to do anything else to verify it?

IMG_3AE841CD32DE-1

kirillzyusko commented 1 week ago

You can toggle this button do some interactions in the app and stop profiling to be sure that performance profile is actually generated.

But you'll need to use Google Chrome, since Safari doesn't support this feature.

puneetlath commented 1 week ago

I tried it on iOS Chrome, but the profile was empty. It just had:

{"traceEvents":[],"samples":[],"stackFrames":[]}%

Does it work for you @kirillzyusko?

kirillzyusko commented 3 days ago

@puneetlath I've observed, that sometimes profile can not be generated and we just generate an empty stack trace (it happens randomly). But if I try second time, then everything works well 🤷‍♂️ I haven't figured out why it happens exactly, but may I ask you to try several times? Typically if the first time it was generated empty, then the second time you should get a real report 😅

puneetlath commented 2 days ago

I tried many times in iOS Chrome on both staging and production and it was empty every time. Very weird! Any ideas?

kirillzyusko commented 1 day ago

@puneetlath you are right, I've just tested Google Chrome iOS and I also can not generate a proper report. I think on iOS a self profiling is simply not supported (irrespective to the browser that you use) 😔

It's kind of weird, because on desktop we have a difference between Chrome/Safari, but on mobile it looks like both browsers behave in the same way 🤔

puneetlath commented 1 day ago

Ah ok got it. But it works on Android?

kirillzyusko commented 1 day ago

@puneetlath yes, Android should work fine :)

puneetlath commented 1 day ago

Ok cool. Closing out then!