Merge lp:~tiagosh/messaging-app/improve_startup_time into lp:messaging-app

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 215
Merged at revision: 217
Proposed branch: lp:~tiagosh/messaging-app/improve_startup_time
Merge into: lp:messaging-app
Prerequisite: lp:~renatofilho/messaging-app/use-contactlistmodel
Diff against target: 380 lines (+117/-77)
7 files modified
src/qml/MMS/Previewer.qml (+47/-0)
src/qml/MainPage.qml (+3/-24)
src/qml/MessageBubble.qml (+1/-1)
src/qml/Messages.qml (+23/-2)
src/qml/MessagesListView.qml (+2/-0)
src/qml/ThreadDelegate.qml (+2/-0)
src/qml/messaging-app.qml (+39/-50)
To merge this branch: bzr merge lp:~tiagosh/messaging-app/improve_startup_time
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Bill Filler (community) Needs Fixing
Review via email: mp+232770@code.launchpad.net

Commit message

Improve startup time

Description of the change

Improve startup time

--Checklist--

Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~renatofilho/messaging-app/use-contactlistmodel/+merge/231017

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/messaging-app) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
N/A

If you changed UI labels, did you update the pot file?
N/A

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
210. By Tiago Salem Herrmann

fix focus on first run

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
211. By Tiago Salem Herrmann

reenable dynamicsortfilter

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
212. By Tiago Salem Herrmann

avoid calling threadForParticipants() more than once

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
213. By Tiago Salem Herrmann

improve a bit more startup

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

Seems better but noticing a few issues:
1) The first time I load a conversation that has lots of sent messages at the end, I see the green bubbles paint initially without the arrow on the right but instead it shows an ugly black square that eventually turns into the arrow on the right of the bubble. This is definitely a new issue either with this MR or something in silo 3

2) From the main chat view, select a conversation to open from a contact. When the thread view is opened, instead of showing the contact name in the header it shows the phone number (and Add Contact button on right) for at least 1 second before switching to show the contact name and proper contact icon. This delay is much longer then it used to be. We should show the contact name immediately when showing the view, as we already know it because we selected it from the previous chats page and shouldn't have to first show the number then switch.

review: Needs Fixing
214. By Tiago Salem Herrmann

avoid displaying a black square.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
215. By Tiago Salem Herrmann

reuse ContactWatcher instance

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
No, but not related to this MR.

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/MMS/Previewer.qml'
2--- src/qml/MMS/Previewer.qml 2014-08-11 22:59:14 +0000
3+++ src/qml/MMS/Previewer.qml 2014-09-04 03:08:58 +0000
4@@ -50,4 +50,51 @@
5 }
6 }
7 }
8+
9+ Component {
10+ id: resultComponent
11+ ContentItem {}
12+ }
13+
14+ Page {
15+ id: picker
16+ visible: false
17+ property var curTransfer
18+ property var url
19+ property var handler
20+ property var contentType: getContentType(url)
21+
22+ function __exportItems(url) {
23+ if (picker.curTransfer.state === ContentTransfer.InProgress)
24+ {
25+ picker.curTransfer.items = [ resultComponent.createObject(mainView, {"url": url}) ];
26+ picker.curTransfer.state = ContentTransfer.Charged;
27+ }
28+ }
29+
30+ ContentPeerPicker {
31+ visible: parent.visible
32+ contentType: picker.contentType
33+ handler: picker.handler
34+
35+ onPeerSelected: {
36+ picker.curTransfer = peer.request();
37+ mainStack.pop();
38+ if (picker.curTransfer.state === ContentTransfer.InProgress)
39+ picker.__exportItems(picker.url);
40+ }
41+ onCancelPressed: mainStack.pop();
42+ }
43+
44+ Connections {
45+ target: picker.curTransfer !== null ? picker.curTransfer : null
46+ onStateChanged: {
47+ console.log("curTransfer StateChanged: " + picker.curTransfer.state);
48+ if (picker.curTransfer.state === ContentTransfer.InProgress)
49+ {
50+ picker.__exportItems(picker.url);
51+ }
52+ }
53+ }
54+ }
55 }
56
57=== modified file 'src/qml/MainPage.qml'
58--- src/qml/MainPage.qml 2014-08-28 05:31:01 +0000
59+++ src/qml/MainPage.qml 2014-09-04 03:08:58 +0000
60@@ -19,8 +19,8 @@
61 import QtQuick 2.2
62 import Ubuntu.Components 1.1
63 import Ubuntu.Components.ListItems 0.1 as ListItem
64+import Ubuntu.Contacts 0.1
65 import Ubuntu.History 0.1
66-import Ubuntu.Contacts 0.1
67 import "dateUtils.js" as DateUtils
68
69 LocalPageWithBottomEdge {
70@@ -37,10 +37,8 @@
71 title: selectionMode ? " " : i18n.tr("Chats")
72
73 bottomEdgeEnabled: !selectionMode && !searching
74- bottomEdgePageComponent: Messages {
75- active: false
76- }
77 bottomEdgeTitle: i18n.tr("Create new")
78+ bottomEdgePageComponent: Messages { active: false }
79
80 TextField {
81 id: searchField
82@@ -146,25 +144,6 @@
83 }
84 }
85
86- HistoryThreadGroupingProxyModel {
87- id: sortProxy
88- sortRole: HistoryThreadModel.LastEventTimestampRole
89- sourceModel: threadModel
90- ascending: false
91- groupingProperty: "participants"
92- }
93-
94- HistoryThreadModel {
95- id: threadModel
96- type: HistoryThreadModel.EventTypeText
97- sort: HistorySort {
98- sortField: "lastEventTimestamp"
99- sortOrder: HistorySort.DescendingOrder
100- }
101- filter: HistoryFilter {
102- }
103- }
104-
105 Component {
106 id: sectionDelegate
107 Item {
108@@ -223,6 +202,7 @@
109 properties["accountId"] = accountId
110 properties["participants"] = participants
111 properties["keyboardFocus"] = false
112+ properties["contactWatcher"] = contactWatcher
113 mainStack.push(Qt.resolvedUrl("Messages.qml"), properties)
114 }
115 }
116@@ -239,7 +219,6 @@
117 }
118 }
119 }
120-
121 }
122
123 KeyboardRectangle {
124
125=== modified file 'src/qml/MessageBubble.qml'
126--- src/qml/MessageBubble.qml 2014-08-28 21:58:57 +0000
127+++ src/qml/MessageBubble.qml 2014-09-04 03:08:58 +0000
128@@ -140,7 +140,7 @@
129
130 source: Qt.resolvedUrl("./assets/conversation_bubble_arrow.png")
131 color: root.color
132- asynchronous: true
133+ asynchronous: false
134 anchors {
135 bottom: parent.bottom
136 bottomMargin: units.gu(2)
137
138=== modified file 'src/qml/Messages.qml'
139--- src/qml/Messages.qml 2014-09-04 03:08:58 +0000
140+++ src/qml/Messages.qml 2014-09-04 03:08:58 +0000
141@@ -37,6 +37,7 @@
142 property QtObject account: mainView.account
143
144 property variant participants: []
145+ property variant previousParticipants: []
146 property bool groupChat: participants.length > 1
147 property bool keyboardFocus: true
148 property alias selectionMode: messageList.isInSelectionMode
149@@ -46,9 +47,18 @@
150 property var activeTransfer: null
151 property int activeAttachmentIndex: -1
152 property var sharedAttachmentsTransfer: []
153+ property QtObject contactWatcher: contactWatcherInternal
154 property string lastFilter: ""
155 property string text: ""
156
157+ onContactWatcherChanged: {
158+ if (!contactWatcher) {
159+ // use the internal contactWatcher if the previous instance
160+ // was deleted
161+ contactWatcher = contactWatcherInternal
162+ }
163+ }
164+
165 function addAttachmentsToModel(transfer) {
166 for (var i = 0; i < transfer.items.length; i++) {
167 var attachment = {}
168@@ -149,6 +159,9 @@
169 eventModel.filter = null
170 return
171 }
172+ if (previousParticipants.join('') === participants.join('')) {
173+ return
174+ }
175 var componentUnion = "import Ubuntu.History 0.1; HistoryUnionFilter { %1 }"
176 var componentFilters = ""
177 for (var i in telepathyHelper.accountIds) {
178@@ -170,6 +183,7 @@
179 var finalString = componentUnion.arg(componentFilters)
180 eventModel.filter = Qt.createQmlObject(finalString, eventModel)
181 lastFilter = componentFilters
182+ previousParticipants = participants
183 }
184 }
185
186@@ -339,8 +353,15 @@
187 }
188
189 ContactWatcher {
190- id: contactWatcher
191- phoneNumber: participants.length > 0 ? participants[0] : ""
192+ id: contactWatcherInternal
193+ phoneNumber: {
194+ if (contactWatcher != contactWatcherInternal || participants.length === 0) {
195+ // dont update if we are using another contact watcher or the list
196+ // of participants is empty
197+ return ""
198+ }
199+ return participants[0]
200+ }
201 }
202
203 onParticipantsChanged: {
204
205=== modified file 'src/qml/MessagesListView.qml'
206--- src/qml/MessagesListView.qml 2014-08-25 19:56:17 +0000
207+++ src/qml/MessagesListView.qml 2014-09-04 03:08:58 +0000
208@@ -55,6 +55,8 @@
209 listModel: participants.length > 0 ? sortProxy : null
210 verticalLayoutDirection: ListView.BottomToTop
211 highlightFollowsCurrentItem: true
212+ // this is to keep the scrolling smooth
213+ cacheBuffer: units.gu(10)*20
214 currentIndex: 0
215 _availableActions: [
216 Action {
217
218=== modified file 'src/qml/ThreadDelegate.qml'
219--- src/qml/ThreadDelegate.qml 2014-08-28 05:28:58 +0000
220+++ src/qml/ThreadDelegate.qml 2014-09-04 03:08:58 +0000
221@@ -31,6 +31,7 @@
222 property string phoneNumber: delegateHelper.phoneNumber
223 property bool unknownContact: delegateHelper.isUnknown
224 property string threadId: model.threadId
225+ property QtObject contactWatcher: delegateHelper.contactWatcher
226 property string groupChatLabel: {
227 var firstRecipient
228 if (unknownContact) {
229@@ -222,6 +223,7 @@
230 property alias subTypes: phoneDetail.subTypes
231 property alias contexts: phoneDetail.contexts
232 property alias isUnknown: watcherInternal.isUnknown
233+ property QtObject contactWatcher: watcherInternal
234 property string phoneNumberSubTypeLabel: ""
235
236 function updateSubTypeLabel() {
237
238=== modified file 'src/qml/messaging-app.qml'
239--- src/qml/messaging-app.qml 2014-08-19 19:43:39 +0000
240+++ src/qml/messaging-app.qml 2014-09-04 03:08:58 +0000
241@@ -19,10 +19,10 @@
242 import QtQuick 2.2
243 import Qt.labs.settings 1.0
244 import Ubuntu.Components 1.1
245-import Ubuntu.Components.ListItems 0.1 as ListItem
246 import Ubuntu.Components.Popups 0.1
247 import Ubuntu.Telephony 0.1
248 import Ubuntu.Content 0.1
249+import Ubuntu.History 0.1
250
251 MainView {
252 id: mainView
253@@ -65,7 +65,6 @@
254 Component.onCompleted: {
255 i18n.domain = "messaging-app"
256 i18n.bindtextdomain("messaging-app", i18nDirectory)
257- mainStack.push(Qt.resolvedUrl("MainPage.qml"))
258 }
259
260 Connections {
261@@ -78,6 +77,42 @@
262 }
263 }
264
265+ HistoryThreadModel {
266+ id: threadModel
267+ type: HistoryThreadModel.EventTypeText
268+ sort: HistorySort {
269+ sortField: "lastEventTimestamp"
270+ sortOrder: HistorySort.DescendingOrder
271+ }
272+ filter: HistoryFilter {}
273+ }
274+
275+ // the model depends on dbus calls, so we instantiate it as earlier as possible
276+ // to improve a bit the startup time
277+ HistoryThreadGroupingProxyModel {
278+ id: sortProxy
279+ sortRole: HistoryThreadModel.LastEventTimestampRole
280+ sourceModel: threadModel
281+ ascending: false
282+ groupingProperty: "participants"
283+ // WORKAROUND: remove this once the sort model is replaced by something else.
284+ // the dynamicSortFilter during startup causes bindings
285+ // to be re-evaluated multiple times
286+ dynamicSortFilter: false
287+ onCountChanged: {
288+ if (count > 0) {
289+ timer.start()
290+ }
291+ }
292+ }
293+
294+ Timer {
295+ id: timer
296+ repeat: false
297+ interval: 10
298+ onTriggered: sortProxy.dynamicSortFilter = true
299+ }
300+
301 Settings {
302 id: settings
303 category: "DualSim"
304@@ -85,11 +120,6 @@
305 property int mainViewDontAskCount: 0
306 }
307
308- Component {
309- id: resultComponent
310- ContentItem {}
311- }
312-
313 Connections {
314 target: ContentHub
315 onShareRequested: {
316@@ -100,48 +130,6 @@
317 }
318 }
319
320- Page {
321- id: picker
322- visible: false
323- property var curTransfer
324- property var url
325- property var handler
326- property var contentType: getContentType(url)
327-
328- function __exportItems(url) {
329- if (picker.curTransfer.state === ContentTransfer.InProgress)
330- {
331- picker.curTransfer.items = [ resultComponent.createObject(mainView, {"url": url}) ];
332- picker.curTransfer.state = ContentTransfer.Charged;
333- }
334- }
335-
336- ContentPeerPicker {
337- visible: parent.visible
338- contentType: picker.contentType
339- handler: picker.handler
340-
341- onPeerSelected: {
342- picker.curTransfer = peer.request();
343- mainStack.pop();
344- if (picker.curTransfer.state === ContentTransfer.InProgress)
345- picker.__exportItems(picker.url);
346- }
347- onCancelPressed: mainStack.pop();
348- }
349-
350- Connections {
351- target: picker.curTransfer !== null ? picker.curTransfer : null
352- onStateChanged: {
353- console.log("curTransfer StateChanged: " + picker.curTransfer.state);
354- if (picker.curTransfer.state === ContentTransfer.InProgress)
355- {
356- picker.__exportItems(picker.url);
357- }
358- }
359- }
360- }
361-
362 signal applicationReady
363
364 function startsWith(string, prefix) {
365@@ -168,7 +156,7 @@
366 function startNewMessage() {
367 var properties = {}
368 emptyStack()
369- mainStack.push(Qt.resolvedUrl("Messages.qml"), properties)
370+ mainStack.currentPage.showBottomEdgePage(Qt.resolvedUrl("Messages.qml"))
371 }
372
373 function startChat(phoneNumber) {
374@@ -196,5 +184,6 @@
375 id: mainStack
376
377 objectName: "mainStack"
378+ Component.onCompleted: mainStack.push(Qt.resolvedUrl("MainPage.qml"))
379 }
380 }

Subscribers

People subscribed via source and target branches