Merge lp:~abreu-alexandre/ubuntu-html5-theme/rtm-fix-webkit-launch into lp:ubuntu-html5-theme/rtm-14.09

Proposed by Alexandre Abreu
Status: Merged
Approved by: Alexandre Abreu
Approved revision: 185
Merged at revision: 184
Proposed branch: lp:~abreu-alexandre/ubuntu-html5-theme/rtm-fix-webkit-launch
Merge into: lp:ubuntu-html5-theme/rtm-14.09
Diff against target: 572 lines (+141/-325)
14 files modified
CMakeLists.txt (+4/-0)
debian/ubuntu-html5-container.install (+0/-1)
src/CMakeLists.txt (+1/-1)
src/plugin/CMakeLists.txt (+0/-1)
src/plugin/Ubuntu/CMakeLists.txt (+0/-1)
src/plugin/Ubuntu/WebApps/CMakeLists.txt (+0/-25)
src/plugin/Ubuntu/WebApps/CordovaLoader.qml (+0/-91)
src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml (+0/-59)
src/plugin/Ubuntu/WebApps/WebAppContainer.qml (+0/-137)
src/plugin/Ubuntu/WebApps/qmldir (+0/-2)
src/ubuntu-html5-app-launcher/CMakeLists.txt (+0/-1)
src/ubuntu-html5-app-launcher/UbuntuJavascriptBindings.qml (+59/-0)
src/ubuntu-html5-app-launcher/main.cpp (+4/-1)
src/ubuntu-html5-app-launcher/main.qml (+73/-5)
To merge this branch: bzr merge lp:~abreu-alexandre/ubuntu-html5-theme/rtm-fix-webkit-launch
Reviewer Review Type Date Requested Status
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+249553@code.launchpad.net

Commit message

Mitigate the QtWebkit / Mainview issue

Description of the change

QtWebkit w/ Qt 5.3 seems to have a race when bundled w/ certain qml elements, something like e.g.:

MainView {

  Page { WebView {} }
}

makes the app (launched as a click) on the devices (w/ RTM or Vivid) spin at startup w/o ever actually showing something,

It does that usually on the first launch, subsequent launches usually work fine. Things do work fine when the Webview is replaced by a Window or even an Item. After some strace and investigation it seems that some bits are racy in QtWebkit in relation w/ its ~/.local/share content.

In the behavior described above, the app goes back into failing mode when one deletes the apps' ~/.local/share. Some cookie DB creation errors (that are not seen consistently though) seem to backup the hypothesis above,

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-12-08 18:08:39 +0000
3+++ CMakeLists.txt 2015-02-12 18:32:50 +0000
4@@ -26,5 +26,9 @@
5 add_custom_target(uninstall
6 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
7
8+# make non compiled files (QML, JS, images, etc.) visible in QtCreator
9+file(GLOB_RECURSE NON_COMPILED_FILES *.qml *.js *.png *.py *.pot *.po *.qdoc *.qdocconf *.css *.html)
10+add_custom_target(NON_COMPILED_TARGET ALL SOURCES ${NON_COMPILED_FILES})
11+
12 add_subdirectory(src)
13 add_subdirectory(tests)
14
15=== modified file 'debian/ubuntu-html5-container.install'
16--- debian/ubuntu-html5-container.install 2014-01-27 18:42:31 +0000
17+++ debian/ubuntu-html5-container.install 2015-02-12 18:32:50 +0000
18@@ -1,3 +1,2 @@
19 usr/bin/ubuntu-html5-app-launcher
20-usr/lib/*/qt5/qml/Ubuntu/WebApps/*
21 usr/share/ubuntu-html5-app-launcher/
22
23=== modified file 'src/CMakeLists.txt'
24--- src/CMakeLists.txt 2014-02-06 22:51:33 +0000
25+++ src/CMakeLists.txt 2015-02-12 18:32:50 +0000
26@@ -1,2 +1,2 @@
27 add_subdirectory(ubuntu-html5-app-launcher)
28-add_subdirectory(plugin)
29+
30
31=== removed directory 'src/plugin'
32=== removed file 'src/plugin/CMakeLists.txt'
33--- src/plugin/CMakeLists.txt 2013-11-27 16:33:23 +0000
34+++ src/plugin/CMakeLists.txt 1970-01-01 00:00:00 +0000
35@@ -1,1 +0,0 @@
36-add_subdirectory(Ubuntu)
37
38=== removed directory 'src/plugin/Ubuntu'
39=== removed file 'src/plugin/Ubuntu/CMakeLists.txt'
40--- src/plugin/Ubuntu/CMakeLists.txt 2013-11-27 16:33:23 +0000
41+++ src/plugin/Ubuntu/CMakeLists.txt 1970-01-01 00:00:00 +0000
42@@ -1,1 +0,0 @@
43-add_subdirectory(WebApps)
44
45=== removed directory 'src/plugin/Ubuntu/WebApps'
46=== removed file 'src/plugin/Ubuntu/WebApps/CMakeLists.txt'
47--- src/plugin/Ubuntu/WebApps/CMakeLists.txt 2013-12-10 16:16:11 +0000
48+++ src/plugin/Ubuntu/WebApps/CMakeLists.txt 1970-01-01 00:00:00 +0000
49@@ -1,25 +0,0 @@
50-project(ubuntu-html5-container)
51-
52-# setup install location
53-execute_process(
54- COMMAND qmake -query QT_INSTALL_QML
55- OUTPUT_VARIABLE QT_INSTALL_QML
56- OUTPUT_STRIP_TRAILING_WHITESPACE
57-)
58-set(HTML5_CONTAINER_IMPORTS_DIR "${QT_INSTALL_QML}/Ubuntu/WebApps")
59-
60-# setup install for local component files
61-file(GLOB QML_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.qml qmldir)
62-install(FILES ${QML_FILES} DESTINATION ${HTML5_CONTAINER_IMPORTS_DIR})
63-
64-# make sure that we have all the files in the right place if we test locally
65-# & have a specific build dir
66-if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
67- foreach(_qmlfile ${QML_FILES})
68- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_qmlfile}
69- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_qmlfile}
70- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${_qmlfile} ${CMAKE_CURRENT_BINARY_DIR}/${_qmlfile})
71- endforeach(_qmlfile)
72- add_custom_target(copy_to_build_dir DEPENDS ${QML_FILES})
73-endif()
74-
75
76=== removed file 'src/plugin/Ubuntu/WebApps/CordovaLoader.qml'
77--- src/plugin/Ubuntu/WebApps/CordovaLoader.qml 2014-12-08 18:08:39 +0000
78+++ src/plugin/Ubuntu/WebApps/CordovaLoader.qml 1970-01-01 00:00:00 +0000
79@@ -1,91 +0,0 @@
80-/*
81- * Copyright 2014 Canonical Ltd.
82- *
83- * This file is part of ubuntu-html5-ui-toolkit.
84- *
85- * ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
86- * it under the terms of the GNU General Public License as published by
87- * the Free Software Foundation; version 3.
88- *
89- * ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
90- * but WITHOUT ANY WARRANTY; without even the implied warranty of
91- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92- * GNU General Public License for more details.
93- *
94- * You should have received a copy of the GNU General Public License
95- * along with this program. If not, see <http://www.gnu.org/licenses/>.
96- */
97-
98-import QtQuick 2.0
99-
100-Item {
101- id: root
102-
103- property string htmlIndexDirectory
104-
105- // Cordova plugin instance
106- property var cordovaInstance: null
107-
108- // the cordova qml instance was created successfully
109- signal created();
110-
111- // an error occured while creating the cordova instance
112- signal creationError();
113-
114- function _tryCreateObject(statement, parent) {
115- var result = null;
116- try {
117- result = Qt.createQmlObject(statement, parent);
118- }
119- catch (e) {};
120-
121- return result;
122- }
123-
124- function _getCordovaObjectCreationStatementFor(version, params) {
125- return 'import CordovaUbuntu '
126- + version
127- + '; CordovaView { '
128- + ' anchors.fill: parent; '
129- + params + ';'
130- + '}';
131- }
132-
133- function _tryCreateCordovaObject(version, params) {
134- var _params = params || '';
135- return _tryCreateObject(_getCordovaObjectCreationStatementFor(version, params), root);
136- }
137-
138- function _ensureCordovaInitDone() {
139- if (cordovaInstance && htmlIndexDirectory.length !== 0) {
140- cordovaInstance.wwwDir = htmlIndexDirectory;
141- }
142- }
143-
144- onHtmlIndexDirectoryChanged: _ensureCordovaInitDone()
145-
146- Component.onCompleted: {
147- // selectively try to load cordova
148- var cordova = null;
149-
150- var candidates = [{version: '3.4', paramString: 'contentFile: "index.html"'}];
151- for (var i = 0; i < candidates.length; ++i) {
152- cordova = _tryCreateCordovaObject(candidates[i].version,
153- candidates[i].paramString);
154- if (cordova)
155- break;
156- }
157-
158- if ( ! cordova) {
159- console.error('Cannot create CordovaView object.');
160- creationError();
161- return;
162- }
163-
164- root.cordovaInstance = cordova;
165-
166- _ensureCordovaInitDone();
167-
168- created();
169- }
170-}
171
172=== removed file 'src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml'
173--- src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 2014-12-08 18:08:39 +0000
174+++ src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 1970-01-01 00:00:00 +0000
175@@ -1,59 +0,0 @@
176-/*
177- * Copyright 2014 Canonical Ltd.
178- *
179- * This file is part of ubuntu-html5-container.
180- *
181- * ubuntu-html5-container is free software; you can redistribute it and/or modify
182- * it under the terms of the GNU General Public License as published by
183- * the Free Software Foundation; version 3.
184- *
185- * webbrowser-app is distributed in the hope that it will be useful,
186- * but WITHOUT ANY WARRANTY; without even the implied warranty of
187- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
188- * GNU General Public License for more details.
189- *
190- * You should have received a copy of the GNU General Public License
191- * along with this program. If not, see <http://www.gnu.org/licenses/>.
192- */
193-
194-import QtQuick 2.0
195-import Ubuntu.UnityWebApps 0.1
196-
197-
198-Item {
199- id: root
200-
201- property var bindingMainWebview: null
202-
203- /*!
204- \internal
205- */
206- function getUnityWebappsProxies() {
207- return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(bindingMainWebview);
208- }
209-
210- /*!
211- \internal
212- */
213- Loader {
214- id: webappBindingsLoader
215- visible: false
216- anchors.fill: parent
217- sourceComponent: bindingMainWebview ? webappBindingsComponent : undefined
218- }
219-
220- /*!
221- \internal
222- */
223- Component {
224- id: webappBindingsComponent
225-
226- UnityWebApps {
227- id: webapps
228- bindee: root
229- injectExtraUbuntuApis: true
230- requiresInit: false
231- }
232- }
233-}
234-
235
236=== removed file 'src/plugin/Ubuntu/WebApps/WebAppContainer.qml'
237--- src/plugin/Ubuntu/WebApps/WebAppContainer.qml 2014-12-08 18:08:39 +0000
238+++ src/plugin/Ubuntu/WebApps/WebAppContainer.qml 1970-01-01 00:00:00 +0000
239@@ -1,137 +0,0 @@
240-/*
241- * Copyright 2014 Canonical Ltd.
242- *
243- * This file is part of ubuntu-html5-container.
244- *
245- * ubuntu-html5-container is free software; you can redistribute it and/or modify
246- * it under the terms of the GNU General Public License as published by
247- * the Free Software Foundation; version 3.
248- *
249- * webbrowser-app is distributed in the hope that it will be useful,
250- * but WITHOUT ANY WARRANTY; without even the implied warranty of
251- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
252- * GNU General Public License for more details.
253- *
254- * You should have received a copy of the GNU General Public License
255- * along with this program. If not, see <http://www.gnu.org/licenses/>.
256- */
257-
258-import QtQuick 2.0
259-import Ubuntu.Components 0.1
260-import Ubuntu.Components.Extras.Browser 0.1
261-
262-
263-/*!
264- \qmltype WebAppContainer
265- \inqmlmodule Ubuntu.WebApps 0.1
266- \ingroup ubuntu
267- \brief WebAppContainer is the root element that should be used for all HTML5 applications.
268-*/
269-MainView {
270- id: root
271- objectName: "root"
272- anchorToKeyboard: true
273- automaticOrientation: true
274-
275- /*!
276- \preliminary
277- The property holds the path to the filesystem location where the 'index.html'
278- file can be found (root of the HTML5 application).
279-
280- The path is absolute or relative to the current dir.
281- */
282- property alias htmlIndexDirectory: cordovaWebviewProvider.htmlIndexDirectory
283-
284- Page {
285- id: mainPage
286- anchors.fill: parent
287-
288- /*!
289- \internal
290- */
291- CordovaLoader {
292- id: cordovaWebviewProvider
293- anchors.fill: parent
294- onCreationError: {
295- mainPage._onCordovaCreationError();
296- }
297- onCreated: {
298- bindings.bindingMainWebview = Qt.binding(function() {
299- return cordovaInstance.mainWebview;
300- });
301- }
302- }
303-
304- /*!
305- \internal
306- */
307- function _onCordovaCreationError() {
308- mainPage._fallbackToWebview();
309- }
310-
311- /*!
312- \internal
313- */
314- function _fallbackToWebview() {
315- console.debug('Falling back on the plain Webview backend.')
316-
317- webviewFallbackComponentLoader.sourceComponent = Qt.binding(function() {
318- return root.htmlIndexDirectory.length !== 0
319- ? webviewFallbackComponent : null;
320- });
321- }
322-
323- /*!
324- \internal
325- */
326- function _getAppStartupIndexFileUri() {
327- return 'file://' + root.htmlIndexDirectory + '/index.html';
328- }
329-
330- /*!
331- \internal
332- */
333- Loader {
334- id: webviewFallbackComponentLoader
335- anchors.fill: parent
336- onLoaded: {
337- bindings.bindingMainWebview = item;
338- }
339- }
340-
341- /*!
342- \internal
343- */
344- Component {
345- id: webviewFallbackComponent
346- UbuntuWebView {
347- url: mainPage._getAppStartupIndexFileUri()
348-
349- experimental.preferences.localStorageEnabled: true
350- experimental.preferences.offlineWebApplicationCacheEnabled: true
351- experimental.preferences.universalAccessFromFileURLsAllowed: true
352- experimental.preferences.webGLEnabled: true
353-
354- experimental.databaseQuotaDialog: Item {
355- Timer {
356- interval: 1
357- running: true
358- onTriggered: {
359- model.accept(model.expectedUsage)
360- }
361- }
362- }
363- // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable
364- experimental.preferences.developerExtrasEnabled: true
365- }
366- }
367-
368- /*!
369- \internal
370- */
371- UbuntuJavascriptBindings {
372- id: bindings
373- }
374- }
375-}
376-
377
378=== removed file 'src/plugin/Ubuntu/WebApps/qmldir'
379--- src/plugin/Ubuntu/WebApps/qmldir 2013-11-27 16:33:23 +0000
380+++ src/plugin/Ubuntu/WebApps/qmldir 1970-01-01 00:00:00 +0000
381@@ -1,2 +0,0 @@
382-module Ubuntu.WebApps
383-WebAppContainer 0.1 WebAppContainer.qml
384
385=== modified file 'src/ubuntu-html5-app-launcher/CMakeLists.txt'
386--- src/ubuntu-html5-app-launcher/CMakeLists.txt 2014-02-06 22:51:33 +0000
387+++ src/ubuntu-html5-app-launcher/CMakeLists.txt 2015-02-12 18:32:50 +0000
388@@ -26,7 +26,6 @@
389 file(GLOB QML_FILES *.qml)
390 install(FILES ${QML_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/ubuntu-html5-app-launcher/qml)
391
392-
393 # install bin files
394 install(TARGETS ${HTML5_LAUNCHER}
395 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
396
397=== added file 'src/ubuntu-html5-app-launcher/UbuntuJavascriptBindings.qml'
398--- src/ubuntu-html5-app-launcher/UbuntuJavascriptBindings.qml 1970-01-01 00:00:00 +0000
399+++ src/ubuntu-html5-app-launcher/UbuntuJavascriptBindings.qml 2015-02-12 18:32:50 +0000
400@@ -0,0 +1,59 @@
401+/*
402+ * Copyright 2014 Canonical Ltd.
403+ *
404+ * This file is part of ubuntu-html5-container.
405+ *
406+ * ubuntu-html5-container is free software; you can redistribute it and/or modify
407+ * it under the terms of the GNU General Public License as published by
408+ * the Free Software Foundation; version 3.
409+ *
410+ * webbrowser-app is distributed in the hope that it will be useful,
411+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
412+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
413+ * GNU General Public License for more details.
414+ *
415+ * You should have received a copy of the GNU General Public License
416+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
417+ */
418+
419+import QtQuick 2.0
420+import Ubuntu.UnityWebApps 0.1
421+
422+
423+Item {
424+ id: root
425+
426+ property var bindingMainWebview: null
427+
428+ /*!
429+ \internal
430+ */
431+ function getUnityWebappsProxies() {
432+ return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(bindingMainWebview);
433+ }
434+
435+ /*!
436+ \internal
437+ */
438+ Loader {
439+ id: webappBindingsLoader
440+ visible: false
441+ anchors.fill: parent
442+ sourceComponent: bindingMainWebview ? webappBindingsComponent : undefined
443+ }
444+
445+ /*!
446+ \internal
447+ */
448+ Component {
449+ id: webappBindingsComponent
450+
451+ UnityWebApps {
452+ id: webapps
453+ bindee: root
454+ injectExtraUbuntuApis: true
455+ requiresInit: false
456+ }
457+ }
458+}
459+
460
461=== modified file 'src/ubuntu-html5-app-launcher/main.cpp'
462--- src/ubuntu-html5-app-launcher/main.cpp 2014-12-08 18:08:39 +0000
463+++ src/ubuntu-html5-app-launcher/main.cpp 2015-02-12 18:32:50 +0000
464@@ -217,7 +217,11 @@
465
466 setUpQmlImportPathIfNecessary(plugin_path);
467
468+
469 QQuickView view;
470+ view.rootContext()->setContextProperty(
471+ "HtmlIndexDirectory", wwwFolder.canonicalFilePath());
472+
473 view.setSource(QUrl::fromLocalFile(Webapp::Config::getContainerMainQmlPath()
474 + "/main.qml"));
475 if (view.status() != QQuickView::Ready)
476@@ -225,7 +229,6 @@
477 qCritical() << "Main application component cannot be loaded.";
478 return EXIT_FAILURE;
479 }
480- view.rootObject()->setProperty("htmlIndexDirectory", wwwFolder.canonicalFilePath());
481
482 view.setTitle(QCoreApplication::applicationName());
483 view.setResizeMode(QQuickView::SizeRootObjectToView);
484
485=== modified file 'src/ubuntu-html5-app-launcher/main.qml'
486--- src/ubuntu-html5-app-launcher/main.qml 2014-12-08 18:08:39 +0000
487+++ src/ubuntu-html5-app-launcher/main.qml 2015-02-12 18:32:50 +0000
488@@ -17,11 +17,79 @@
489 */
490
491 import QtQuick 2.0
492-import Ubuntu.Components 0.1
493-import Ubuntu.WebApps 0.1
494-
495-WebAppContainer {
496+import Ubuntu.Components 1.0
497+import Ubuntu.Components.Extras.Browser 0.1
498+import QtWebKit.experimental 1.0
499+
500+MainView {
501+ id: root
502+
503 width: units.gu(100)
504 height: units.gu(75)
505+
506+ anchorToKeyboard: true
507+ automaticOrientation: true
508+
509+ Timer {
510+ id: checkTimer
511+ running: true
512+ repeat: false
513+ onTriggered: {
514+ webviewComponentLoader.sourceComponent =
515+ webviewComponent
516+ checkTimer.stop()
517+ }
518+ interval: 100
519+ }
520+
521+ Page {
522+ anchors.fill: parent
523+ Loader {
524+ id: webviewComponentLoader
525+ anchors.fill: parent
526+ onLoaded: {
527+ bindings.bindingMainWebview =
528+ webviewComponentLoader.item;
529+ }
530+ }
531+ }
532+
533+ Component {
534+ id: webviewComponent
535+
536+ UbuntuWebView {
537+ maximumFlickVelocity: height * 5
538+
539+ url: HtmlIndexDirectory !== "" ? ('file://' + HtmlIndexDirectory + '/index.html') : ""
540+
541+ experimental.preferences.localStorageEnabled: true
542+ experimental.preferences.offlineWebApplicationCacheEnabled: true
543+ experimental.preferences.universalAccessFromFileURLsAllowed: true
544+ experimental.preferences.webGLEnabled: true
545+
546+ experimental.databaseQuotaDialog: Item {
547+ Timer {
548+ interval: 1
549+ running: true
550+ onTriggered: {
551+ model.accept(model.expectedUsage)
552+ }
553+ }
554+ }
555+
556+ // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable
557+ experimental.preferences.developerExtrasEnabled: true
558+
559+ onNewTabRequested: {
560+ if (url.toString().indexOf("file://") !== 0) {
561+ Qt.openUrlExternally(url.toString())
562+ return
563+ }
564+ }
565+ }
566+ }
567+
568+ UbuntuJavascriptBindings {
569+ id: bindings
570+ }
571 }
572-

Subscribers

People subscribed via source and target branches