Open jgibbon opened 4 years ago
Prioritization:
The only really bad thing that I can't handle without some context is 1.3 from the OverviewPage:
1.3 :question::question: Is
redrawModel
really, really needed? It recreates all rendered delegates AFAICT, which is a bit heavy & weird on init. Almost all other init issues' impact gets doubled by this one, I think.
The other things either aren't really bad or I can fix them myself.
Slightly off topic but since opacity animation was referenced.... There're two ways to bind opacity and visibility. This:
visible: opacity > 0
opacity: needToDisplay ? 1 : 0
and this:
opacity: visible ? 1 : 0
visible: needToDisplay
Both make sense but behave differently with respect to opacity animation. In the first case visible: opacity > 0
the item's opacity is being animated both ways, when it's appearing and when it's disappearing. In the second case opacity would be animated only when the item is appearing on the screen. When visible becomes false, the item disappears immediately regardless of its opacity.
I typically use the first variant by default.
And yes, it's a good idea to set visible to false for the items which are not needed, to completely remove them from the event processing chain.
I would also look towards using enums (e.g. for chat/message types) and compare numbers rather than strings. C++ part (exposing more enums and associated roles from the models) need to be done first, and in that sense doesn't interfere at all with QML-only optimization.
Using TDLibFile
can remove some signal processing from QML and push it to native code which should be good for performance.
Not off topic at all, that is a very good point! I'll make sure to skip 3.1, since it's very much intended.
Using TDLibFile is also a good addition.
I initially only thought about optimizing
OverviewPage
, because that didn't get much love, yet. But then someChatPage
issues "popped up", as well.As I am not able to assess all of those points (not very familiar with how/why some of these things were done exactly, especially c++ interaction), I'd appreciate some feedback (or even implementation help later on) at least on the less obvious ones marked with :question::question:. They are numbered to make referencing a tiny bit easier.
1. OverviewPage
opacity
fade when loading gets false does stutter a bit. It will already be better if the other issues here are done. :question::question: Alternatively: Handleloaded
in aTimer
(maybe an existing one), as well?updateContent()
onStatusChanged
which means also onPageStack.pop
. :question::question: Do we need that for all calls inside? Or would it be enough to call (some of them?) on init?redrawModel
really, really needed? It recreates all rendered delegates AFAICT, which is a bit heavy & weird on init. Almost all other init issues' impact gets doubled by this one, I think.onChatChanged
: Doesn't do much, but it gets called a lot. Thousands of times on init for me. Do we really still need that?chatListModel
even need to emit it multiple times on init?ContextMenu
Loader
workaround fromChatPage
, as well. Profiler shows quite a bit of time wasted here.precalculatedValues
to reduce time spend on repeated (mostlywidth
) bindings/calculations uselessly, which according to the Profiler adds up on init/while scrolling.2. ChatPage
viewMessage
if the last read index <lastQueuedIndex
?2.2 MessageListViewItem
chatModel
Connections
onMessagesIncrementalUpdate
:chatModel.getLastReadMessageIndex
gets called for every message instance after every scrolllastReadMessageIndex
intoprecalculatedValues
, bind everything to that (also for the other signals)chatModel
need to emit it every time, even if nothing changed?onLastReadSentMessageUpdated
: gets called for every visible message? Perhaps that can get handled withprecalculatedValues
, too?getMessageStatusText
: put inside messageDateText, call directly without parameters (DRY). Perhaps cache the old text to prevent unneeded emojify calls? Or use arawText
property to change & don't touch the text binding at all – it should then be updated when the other properties change, as well. Maybe there's also something to be optimized with thelastReadSentIndex
checking inside.model.display.type['@type'] === "chatTypePrivate"
with chat_type check?3. visible/opacity bindings
Some bindings are checked twice instead of just checking on
visible
and referring to that, orvisible
even rechecks on every change of theopacity
Behavior
:ProfileThumbnail
: MakeprofileImageComponent
svisible
binding dependent ofsingleImage.status
, andopacity
dependent on it (switch around), or it may get called pretty often because ofopacity
sBehavior
. This exact issue is also present inStickerPreview
(twice),ImagePage
andInitializationPage
.BackgroundProgressIndicator
: useopacity: visible ? 1.0 : 0.0
ImagePreview
/LocationPreview
singleImage
: see aboveStickerPicker
stickerPickerFlickable
/loading column: see aboveOverviewPage
loading column: see above (mind negative value)WebPagePreview
singleImage: see abovePinnedMessageItem
unpinMessageIconLoader
is theBehavior on opacity
even used?4. CoverPage
tdLibWrapper.getAuthorizationState()
&tdLibWrapper.getConnectionState()
and adding connections to listen to changes for themselves. This could be merged in applicationWindow. This would reduce the need for the JS functionssetUnreadInfoText
(CoverPage) andsetPageStatus
, as well, in favour of more optimized bindings.Text.PlainText
. I guess there are dozens of other places where we know we don't have emojis/html. This could be implemented globally.