Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8DFC6E8B1 for ; Wed, 9 Jan 2013 03:23:34 +0000 (UTC) Received: (qmail 70171 invoked by uid 500); 9 Jan 2013 03:23:34 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 70032 invoked by uid 500); 9 Jan 2013 03:23:33 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 69990 invoked by uid 99); 9 Jan 2013 03:23:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jan 2013 03:23:31 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of agrieve@google.com designates 209.85.214.178 as permitted sender) Received: from [209.85.214.178] (HELO mail-ob0-f178.google.com) (209.85.214.178) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jan 2013 03:23:27 +0000 Received: by mail-ob0-f178.google.com with SMTP id eh20so1729946obb.23 for ; Tue, 08 Jan 2013 19:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=5RMooPkn24n6jVIFnabGgBkUUc6lv9Y66yCZKTbe83E=; b=FjV43aXdc+Pp9GH7cClGqTF70JkpGtcOe74D4KVzUNiWrxP7fqTZ+nVfBxFL2XdZ1t OQxwgloGTPN3+iHC6VGH6bko+IOHl2auUEhoSaxE/fKiOdK1BOWHKAajqYQDmkOWgWC/ YsoctvNUEmRq8jPW6PzWx3JDO3PC7zVKU1/b7UXLx0i7EDfaRQilF+Yl5S7LxAaaHUyH XpATtNyBclS5us2QJImm0BQNcFb1BfFZ84ePIuUUZHEDCTFUzSAFwxv27IK5Og7CIoBi XNYMnXvHwecOQ9bYIN3NK7B73ELPHHt1RccZCizVW2mzIVXLcWEV12KMoh7sVwBL+Bl0 CPUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=5RMooPkn24n6jVIFnabGgBkUUc6lv9Y66yCZKTbe83E=; b=eyODJ4km8FbVgGrnjeJir9rSDOGS06YcECVzu8Nw2zFl2f1KaPF0N4hfFhXgVwf4VL 2o117T09N4Ns86BHQ5p6omJ0VXHw20jOxsrXCWkRUd9qFZqgQcN0gGog6Bo6hI7Hx6HD HRoPEnaw5k9NCUywGfTTiciUdoTW2lvFKUCIQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-gm-message-state; bh=5RMooPkn24n6jVIFnabGgBkUUc6lv9Y66yCZKTbe83E=; b=hRTufgAKDwMQ3+xxG7N279aZ0WASGD6q0ON902bNUwfWAPQLOOlwoXo/Y5uKiGdKe0 QPJ5SoVGRs/HhfdGpU36kMulJRP3sF5t0O8mgWrm4sWnEUzG+yYkdIsurJlkDQ5g4CJD OQ1lqHNa78q40/cs1jhWeAC1Ae/2cTqH7yHquiP48tjEZ2ynWhnvwZWGAlyBX5Sl/qI+ rc27tUBcCWRztMdOoy4gJnKD+TYhHzM7CgM6uRQZGVvNwc0owUR1qePq8tpndpkBvGDc mqNrImciAtHja4IUvm9N5vkoRwA39pjfLyQQrhS8tcrC4xiCRIE7sZ8x7yiD8KZbClVf t5dA== Received: by 10.60.171.16 with SMTP id aq16mr36421943oec.37.1357701786713; Tue, 08 Jan 2013 19:23:06 -0800 (PST) MIME-Version: 1.0 Sender: agrieve@google.com Received: by 10.182.183.1 with HTTP; Tue, 8 Jan 2013 19:22:46 -0800 (PST) In-Reply-To: References: From: Andrew Grieve Date: Tue, 8 Jan 2013 22:22:46 -0500 X-Google-Sender-Auth: bg4M1v_6KrK5lbowHrnpTilDZ2o Message-ID: Subject: Re: Binary data across exec bridge To: dev Content-Type: multipart/alternative; boundary=bcaec54d3ef0b53cba04d2d294b0 X-Gm-Message-State: ALoCoQlKaIE4R9X5l5u73WKLv9ADXvrJeofc8ztkEHpg7SqlvJ9VDCfvOb7347XFiIx47L37UFG6Oyruzt4Wdlt3J0bi+UK3/kZ52A99MvLhbuiN8gJyTQVAS3leHi6XDsynUPNOetozK1Vl4vIb/8xhzgvVGhALf8A9hq1Xo2XyhFLN2XkGbRDZ0HxWOPgfmbj+aJTtS2Bi X-Virus-Checked: Checked by ClamAV on apache.org --bcaec54d3ef0b53cba04d2d294b0 Content-Type: text/plain; charset=ISO-8859-1 Rather than "binary data", I think we should focus strictly on "ArrayBuffer". I think the only other binary data concept is Blob, and Blob is easy to create from an ArrayBuffer. As for how to have one of these show up in a JSON object, I think it will be tough to make this work. Most platforms assume that you can paste the JSON into an eval / JSON.parse, and it will come out correctly. That can't be the case for ArrayBuffers. Maybe we should just not support this. The use-case here is being able to pass multiple values to callbacks. For ArrayBuffers, maybe we can passing the usual payload plus an optional ArrayBuffer as an additional parameter. I don't think it would be necessary to have multiple ArrayBuffers for a single callback... My ideas for transferring this over the bridge on iOS include: - an array of numbers - a string of shorts encoded as chars with unicode chars encoded as \uXXXX - a URL that the client can fetch via XHR and we can return the binary data via CDVURLProtocol (advantage here is that XHR2 can request the payload as an ArrayBuffer instead of having to construct the ArrayBuffer after-the-fact For Android, the string of short-encoded chars is probably the best bet since the bridge natively supports transferring strings without having to parse them as JS literals. On Tue, Jan 8, 2013 at 4:05 PM, Michal Mocny wrote: > Created https://issues.apache.org/jira/browse/CB-2173 > > > On Tue, Jan 8, 2013 at 3:52 PM, Michal Mocny wrote: > > > Background: I've been working on implementing chrome.socket [1] for > mobile > > chrome apps [2] and porting circ (an irc chrome app) [3]. Teaser video: > > https://docs.google.com/open?id=0B0UdPHoQPXheTzhTZXZHUlpGWHM (this is > > still in its infancy, and I certainly do plan to submit a version of the > > socket api that will work in cordova without any mobile chrome app > magic). > > > > As part of doing that, I had to implement sending binary data across the > > exec bridge (on ios for now), and I think it may be a good idea to just > add > > that functionality to cordova core. My current implementation is > certainly > > not the best, so I will extend the exec bridge echo benchmarks to test > > binary transfer speeds and we can improve over time. > > > > My first step would be to implement helpers in js/ios/android which > plugin > > devs can call manually to serialize/deserialize binary data into/from > > whatever magical form is most efficient. > > > > Next, I would try to automate these helpers from within the exec call > > (e.g. iterate arguments looking for ArrayBuffer/Blob/etc types before > json > > serialization). As part of doing this, I would need to add "hints" about > > the underlying argument types/some clever way to encode semantic > > information about the arguments list, which we currently do not do. > > > > If anyone has any suggestions or objections please let me know! > > > > -Michal > > > > [1] http://developer.chrome.com/apps/socket.html > > [2] > > > https://github.com/MobileChromeApps/chrome-cordova/blob/master/api/chrome/socket.jsand > > https://github.com/MobileChromeApps/chrome-cordova/tree/master/plugins > > [3] https://github.com/flackr/circ > > > --bcaec54d3ef0b53cba04d2d294b0--