by mrkcsc · 8y ago · 0 comments
In your defense, it's a cancer that all "modern" apps done in javascript suffer from, but still, why?
Edit: for those who don't want to click, it's a screnshot of the os x activity monitor showing the worst memory consumption, in order: Discord Helper 1.98 Gb, kernel_task 1.67 Gb, Skype Helper 1.58 Gb, Slack 1.20 Gb :)
Modern RAM doesn't work the way people who complain about Slack/et al think it does. The operating system will cull it from other places when it needs it; even a native Cocoa app will not dump memory you're done with until the system decides it needs it for something else, because on the off-chance your app ends up needing it again, it's already allocated. "purge" exists for a reason.
It's like when you pull up a StackOverflow answer for "how can I judge how much memory usage my process has?", and the top voted answer is some bash script to determine peak ps, when every other answer tries to explain that that's only one measure of memory and isn't even totally accurate.
Furthermore, that nice feature of most modern apps where you're scrolling up rapidly and an image is nice and ready to present? Images are big, especially when we all use retina displays. They take up memory. There was a blog post that went on HN a few months ago but didn't seem to make the front page, wherein the author determined that forcing Electron to dump image cache junk lowers the memory usage substantially.
Could Electron & co do better? For sure. Loading an entire browser for a UI does kind of suck. But stop acting like all the stuff that the browser does for you _for free_ is or should be zero-cost.
End rant, I guess.
The only reliable way to learn the memory consumption of a process is to somehow make sure other processes don't allocate/deallocate memory, kill the process in question and watch the difference in global memory consumption.
I've seen startup latency much slower than that on my iPhone SE. In the best case, the application takes about six seconds to cold boot when I tap on a notification. Sometimes it's closer to fifteen or twenty seconds if the app sits on the "connecting" screen for a while. It's difficult to understate how much slower the app feels than everything else on my phone.
Meanwhile, we keep working towards to improving our user experience on all the devices especially the lower-end ones (I personally use iPhone 6 as my go-to test device). For instance, we will add caching very soon to shorten the interaction waiting. Hopefully you will enjoy more using Discord on your SE then :)
If we had some magical way to make the dev treadmill run slower than the user treadmill, we'd see better architectures in many cases. In that alternate world it would be easy to precompile the javascript and load 20 times faster.
iOS users tend to run newer devices generally which might lead some devs to feel that this extra optimization isn’t worth the time it takes, but I disagree because it doesn’t benefit only users with older devices – it’ll make your app run better on newer devices too and make it that much more unlikely that your app gets killed or causes the OS to kill other apps in multitasking scenarios (iOS kills resource hogs much more readily). In short, everybody benefits.
With this same thought process, I plan to pick up one of the 120hz iPad Pro models to test on soon. It’s one of the most powerful iOS devices available, but driving 120FPS isn’t easy and given how many apps fail to hit the target of 60FPS on similar hardware I’d bet that a huge number, perhaps even most, don’t come anywhere close to running at 120FPS even with the extra horsepower.
Thanks for all of your work.
And thank you for helping make Rust awesome.
* Have you evaluated cross-platform "native-ish" alternatives? (Nativescript, Flutter, etc.)
* What does the "lack of 64-bit support" mean for Android?
* This can be worked around by deferring work when doing transitions/animations based on user interaction but at the time we only had a single Android Engineer (myself) and I felt it would be an overly large hurdle to cross. The team is however still interested in trying again some point in the future now that we have more time for it.
* The minimum version we support is API level 16 which is quite old and we may eventually bump that to 17.
* We have not evaluated any native-ish alternatives mostly due to bandwidth but also because the goal is to re-use our stores/business logic from the desktop/ios clients so we can move faster.
* On 64-bit support https://github.com/facebook/react-native/issues/2814 it ca be worked around without much consequence but is a consideration as ones application grows in complexity and dependencies.
I believe it's something we may eventually take on - just not currently planned - there are a lot of ways we could make the nitro experience better.
Any other insights would be great, as I'm planning to start converting my web app to RN in the next months and didn't know Android would be a problem.
When we originally got it running on Android (without the chat view since that component is native in the iOS app) we found that it performed quite poorly due to most of our pages being heavy on data and UI - as well as being very reactive (a typical discord server might have hundreds of permissions, messages and users all changing/updating in real time). React Native is single threaded and while iPhone’s have great single threaded performance, Android phones are more reliant on multiple cores and RN as I understand it mostly can’t take advantage of that.
On higher end Android phones the performance was actually fairly acceptable out of the box, but our user base has a lot of gamers who are running very old Android phones from many years ago - and in those situations the lag was unacceptable. For iOS, most users tend to only last one or two hardware generations behind.
Additionally, at the time React Native for Android had just been released and there were a whole host of other issues at the time - bugs and lack of Android specific components like the Navigator (which have since mostly been ironed out).
Today I think it is possible to build a fast React Native Android application and I would recommend someone starting from scratch do so :). However now the challenge is that we have an existing Native Android app so our users already have a baseline expectation of feature parity and performance. If we switch over we must meet or exceed that bar.
The only thing left that really bugs me is the fact that you can't paste images from the clipboard into the message field. It's made me change my entire workflow, from copying images to saving them.
Sorry to use this as a soapbox for my pet issue, but I saw the opportunity :P
So stay tuned!
Thanks for the kind words, the team really appreciates it.
One question that popped up in my while reading the article was would you consider doing the android app in react native if you had to start now ? Or do you still feel it lacks the coherency it has with iOS.
While the performance footprint is mostly the same - the ecosystem and feature set around it has improved a ton to the point where I believe you could get it 90% there very quickly.
One of my friends has a small startup and they went full React Native as a team of two and they describe the Android side as "free" as in they really just focus on iOS and it 90% of the time it also works fine on Android (they care less about older devices at the moment so they don't spend time optimizing for those).
Android inherently will always have challenges due to the vast number of devices and hardware/performance problems but going native isn't a silver bullet either and doesn't shield you from the challenges entirely - it's just a familiar form of pain ;P
I've been using Discord's OAuth and that's been nice, but I what I'd really like is to display that status on my site.
Is this what's expected from the app?
I'm not an expect on voice but iirc we do use a different codec than Skype so the audio is not going to be identical however, we have advanced settings in the `Voice and Video` section of the settings that allows you to enable/disable things like Echo Cancellation and Voice Suppression that could be the cause of the feedback.