WebView.loadHtml() doesn’t wait for context to be fully constructed, may result in user scripts not loaded

Bug #1471779 reported by Michael Zanetti
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Oxide
Confirmed
Medium
Unassigned
Ubuntu Notes app
Fix Committed
Undecided
Unassigned

Bug Description

Seems that since the change with the new header in the NoteView page, the user script in oxide isn't called all the time any more. Of about half the times I retry, the callback just isn't ever called. Closing the note and opening it again seems to make it recover (or break) in about half the times.

My suspicion is a race condition when building up the view, now that with the use of the locationBarController building it has gotten more expensive.

This is the user script:
http://bazaar.launchpad.net/~reminders-app-dev/reminders-app/trunk/view/head:/src/app/qml/ui/reminders-scripts.js

This is the place that installs the user script/listens for callbacks:
http://bazaar.launchpad.net/~reminders-app-dev/reminders-app/trunk/view/head:/src/app/qml/ui/NoteView.qml#L42

Related branches

Revision history for this message
Michael Zanetti (mzanetti) wrote :

A package built from current trunk to reproduce the isse: http://notyetthere.org/data/com.ubuntu.reminders_0.5.466_armhf.click

Here's a screenshot of a note that frequently triggers the issue: http://i.imgur.com/JEbGT17.png

description: updated
Olivier Tilloy (osomon)
summary: - sometimes ticking checkboxes in note view doesn't save the change
+ WebView.loadHtml() doesn’t wait for context to be fully constructed, may
+ result in user scripts not loaded
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Managed to extract the code in question into a standalone app for easier reproducing. See attached archive.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Tested with a standalone reproducer courtesy of Michael, and I was able to reproduce the issue. Some observations:

 - This happens when the WebContext is being instantiated at the same time as the WebView (if both instances are inside a Page). If the WebContext lives outside of the Page, and thus is already instantiated before the WebView, the issue doesn’t exist.

 - This happens only when loadHtml() is being called in the WebView’s Component.onCompleted. If I delay that call by 100msecs, the issue doesn’t exist.

The above two observations seem to indicate that there is a race condition in loadHtml(), that sometimes get called before the context has finished constructing, and thus the user scripts are not loaded.

loadHtml() should probably wait for the context to be fully constructed.

Changed in oxide:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

Fix committed into lp:reminders-app at revision 486, scheduled for release in reminders-app, milestone 2014-11-27

Changed in reminders-app:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.