於 4/30/14, 2:58 AM, Ehsan Akhgari 提到:
> On 2014-04-29, 7:57 AM, Vicamo Yang wrote:
>> 於 4/23/14, 12:23 AM, Ehsan Akhgari 提到:
>>> That sounds fine as far as I'm concerned, but I think that's more of a
>>> gaia call. If there are other reasons for inventing unowned data
>>> stores, please let us know.
>>>
>>> Thanks!
>>> Ehsan
>>>
Basically, without access to data store in Gecko, all control flows
involving IndexedDB access have to be replaced by a Gecko -> Gaia ->
Gecko round-trip. Gecko will then only process almost state-less
requests that interact with network, fire an event/return the result to
notify Gaia, and Gaia sends yet another request to continue remaining
process. For example, a MT SMS transaction has to be torn down to:
1) Gecko notifies Gaia new SMS arrival, wait for ACK request,
2) Gaia request Gecko to send ACK with FCS. However, Gecko may
starve if such request is never issued.
A MT MMS transaction becomes:
1-a) Gecko notifies Gaia new notification indication arrival,
2-a) Gaia requst Gecko to send the notification response, and
optionally start the download. However, Gecko may starve if such
request is never issued, so we may prefer plan-B:
1-b) Gecko notifies Gaia new notification indication arrival and
always send DEFERRED response back to network,
2-b) Gaia request Gecko to retrieve if this message should be
automatically retrieved. However, this method may conflict with
carriers' certificate process because we're not following the
specification -- to initiate retrieve process right away when retrieval
preference is set to automatic.
MobileMessaging API will no longer be the one you calls send() and wait
for everything gets done, neither the one you wait for onreceived
silently. Gaia has to aggressively interact with Gecko, or there will
be unexpected consequences.
We can still come up with some solutions, but each with its own new
challenge. That's fine if we decide it's better. All these things have
been done in one way, then they can surely be done in another way. But
I'd like to highlight that it's not only about conversation groups, it's
about how Gecko interacts with network and how Gaia interacts with
Gecko. We'd better fully aware of where we're heading before the first
step.
In contrast, with access to data store in Gecko, all the following
technical details can still be hidden in Gecko. But some public
interfaces will be removed/modified for sure. For example probably
don't need onreceive/onsent/onfailed, because datastore API emits
onchange events for us. It's true there is a slight semantic difference
for Cost Control app, maybe we don't have to talk about this now.
Removing these events seems not be a big deal, the greatest challenge
will be mapping data store changes to IndexedDB that allows us to
perform various query requests.
>> Gecko MobileMessaging API hides a lot techinical details from Gaia.
>>
>> [One very fundamental problem: ACK received SMS T-PDU]
>>
>> When Gecko receives a incoming SMS T-PDU, it should send an ACK with
>> fail cause to the network. If that message is successfully processed,
>> stored into device storage, you send a FCS_OK back; if there is no more
>> space for this message, send a FCS_MEMORY_CAPACITY_EXCEEDED back;
>> otherwise, FCS_UNSPECIFIED. Moving data store to Gaia and refuse access
>> from Gecko follows Gaia should take the responsibility of sending ACK as
>> well. Gecko has to fire an event to Gaia, make sure Gaia has been
>> notified, and waits for Gaia's instruction to send ACK back. It's
>> doable, just add an API |sendAck(id, failCause)|. We have already
>> onreceived, but how do we make sure that Gaia has been notified and
>> Messages app is not oom-killed during the process remains a question.
>> Without sending an ACK back to network, network may stop further SMS
>> deliverying until next registration.
>>
>>
http://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/RadioInterfaceLayer.js#3092
>>
>
> Would this still be an issue if the SMS was written to the data store
> directly by Gecko?
No. We just need to assure the new arrival can be written to disk
successfully.
>> [Problem-2: no received {Sms,Mms}Message::id field]
>>
>> Since we don't own the data store, it's obvious that we don't have an
>> unique id to provide either. It's true we can provide uuid or just
>> don't give any id any more. However, in the case of a received MMS
>> notification indication, it could be a dup of previously received one
>> because of the lack of networking for a long period like powered off
>> over night. So now you'll get duplicated onreceived events, Gaia has to
>> re-implement dup detection. That's actually fine until you want
>> auto-retrieving. There is no auto-retrieving anymore because Gaia has
>> to decide whether that's a duplicated notification first. We have to
>> pass all necessary parameters in the retrieveMMS() call as well, not
>> just a message id. "There is no message id", a talented child says.
>>
>>
http://mxr.mozilla.org/mozilla-central/source/dom/mobilemessage/src/gonk/MmsService.js#1796
>>
>
> Not sure if I completely understand this issue. Do you have any
> suggestions?
Almost same as above, we need to save the MMS notification indication on
disk before going on to retrieve automatically or sending notification
response. Or, this has to be torn down to some two-step process as
illustrated in 1-a), 2-a), 1-b), 2-b).
Just? No. It also follows we don't have convenient ondeliverysuccess,
ondeliveryerror events for everyone interested in. These events,
because of the lack of message object and message id, have to be further
processed in _every_ listener.
Yup.
>> [Problem-6: message object in retrieveMMS() error event]
>>
>> Bug 824717 requests carrying message object in DOMRequest error event as
>> well. However, for a retrieveMMS() call, the passed parameters are not
>> enough to construct a MmsMessage back.
>>
>>
https://bugzilla.mozilla.org/show_bug.cgi?id=824717
>
> Could we not send the ID for a field in the data store instead?
Yes, that's probably the only way, although it's not as convenient as a
message object.
>> [Problem-7: SmsMessage, MmsMessage interface changes]
>>
>> Not actually a problem, but a task to be forfilled by Gaia. We don't
>> have access to data store, so attributes that may change after be
>> sent/received or may not be accessible at the time firing events have to
>> be removed. Following is a list with reasons:
>>
>> 1) id: see problem-2,
>> 2) threadId: conversation grouping is now a task of Gaia,
>> 3) deliveryStatus/deliveryTimestamp, deliveryInfo: see problem-3,
>> 4) deliveryTimestamp: same for deliveryStatus,
>> 5) read: we'll never know this,
>>
>>
>> All these are not related to conversation grouping. Moving to data
>> store API is _not_ only re-implementing some phone number matching
>> mechanism, but also a great change in current API design and control
>> flow when Gecko don't have access to the data store.
>
> Thanks for raising all of these issues, these are really helpful. Note
> that there is nothing that prevents us from writing to the data store
> from Gecko, and I think that would alleviate a lot of these concerns.
> Please let me know if you agree!
I do. Even if we decide owning data store in apps only is somehow a
better way, then it is a better way. I also need some time to construct
a full picture what will we need when data store is not owned by Gecko.
One trivial thing is SMS/MMS will no longer work without an
appropriately implemented messaging app. "Gecko depends on Gaia's
functionality" is one thing I worry about most.
> Cheers,
> Ehsan
Regards,
Vicamo Yang