Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AA1ECD7B7 for ; Wed, 22 Aug 2012 14:53:43 +0000 (UTC) Received: (qmail 94259 invoked by uid 500); 22 Aug 2012 14:53:43 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 94193 invoked by uid 500); 22 Aug 2012 14:53:43 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 94185 invoked by uid 99); 22 Aug 2012 14:53:43 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Aug 2012 14:53:43 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D85B02C0908 for ; Wed, 22 Aug 2012 14:53:42 +0000 (UTC) Date: Thu, 23 Aug 2012 01:53:42 +1100 (NCT) From: "Andrew Grieve (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <184786566.604.1345647222886.JavaMail.jiratomcat@arcas> In-Reply-To: <1153424107.27209.1336143290128.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CB-638) Slow native bridge (especially android) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13439582#comment-13439582 ] Andrew Grieve commented on CB-638: ---------------------------------- I've checked in the first round of changes for this. Modes can be tested in the mobile-spec exec() benchmark. jsToNativeModes = { PROMPT: 0, JS_OBJECT: 1, LOCATION_CHANGE: 2 // Not yet implemented }, nativeToJsModes = { // Polls for messages using the prompt() bridge. POLLING: 0, // Does an XHR to a local server, which will send back messages. This is // broken on ICS when a proxy server is configured. HANGING_GET: 1, // For LOAD_URL to be viable, it would need to have a work-around for // the bug where the soft-keyboard gets dismissed when a message is sent. LOAD_URL: 2, // For the ONLINE_EVENT to be viable, it would need to intercept all event // listeners (both through addEventListener and window.ononline) as well // as set the navigator property itself. ONLINE_EVENT: 3, // Uses reflection to access private APIs of the WebView that can send JS // to be executed. // Requires Android 3.2.4 or above. PRIVATE_API: 4 }; -I've not implemented the any keyboard work-arounds for LOAD_URL -I've not added a workaround for hiding online/offline events from changing -JS_OBJECT probably needs a better enable/disable detection. Right now it's disabled only for the 2.3 emulator instead of checking for JSC (via http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-andro) Some initial benchmark results from my Galaxy Nexus (echos per second, bigger is better, payload size=500 bytes): Sync JS->Native: PROMPT: 570 JS_OBJECT: 800 Using JS_OBJECT for JS->Native and async Native->Response: Native->JS POLLING+PROMPT: 100 Native->JS HANGING_GET: 75-90 Native->JS LOAD_URL: 160 Native->JS ONLINE_EVENT+PROMPT: 200-270 Native->JS PRIVATE_API: 340 ONLINE_EVENT being faster than LOAD_URL surprised me. Especially since it can be made even a bit faster if it uses JS_OBJECT to retrieve the message instead of PROMPT. Still to do: -Implement LOCATION_CHANGE JS->Native mode -Add detection logic for JS_OBJECT support (this will involve loading a test page to run some JS) -Add hiding of ONLINE_EVENTS changes from the app via cordova.addWindowEventHandler() and navigator.__defineGetter__('onLine', ...) -Make POLLING and ONLINE_EVENT be able to use JS_OBJECT instead of always PROMPT. -Make POLLING & HANGING_GET retrieve all pending messages in one call instead of one at a time -Add mobile-spec test that ensures all modes work (when expected to) Final Steps: -Discuss changing the default bridge mode, as well as how to implement fall-back modes. > Slow native bridge (especially android) > --------------------------------------- > > Key: CB-638 > URL: https://issues.apache.org/jira/browse/CB-638 > Project: Apache Cordova > Issue Type: Improvement > Components: Android > Reporter: Lee Crossley > Assignee: Andrew Grieve > Priority: Critical > Labels: 2.1.0 > > Doing many native callbacks (such as writing files) has a significant overhead. > Trigger.io's native bridge is more than 5 times faster than Cordova (on Android). http://trigger.io/cross-platform-application-development-blog/wp-content/uploads/2012/02/chart_1-21.png > I'd love to see similar performance stats in Cordova. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira