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 54F56D9C8 for ; Thu, 6 Sep 2012 15:28:10 +0000 (UTC) Received: (qmail 34130 invoked by uid 500); 6 Sep 2012 15:28:10 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 34096 invoked by uid 500); 6 Sep 2012 15:28:10 -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 34085 invoked by uid 99); 6 Sep 2012 15:28:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2012 15:28:10 +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 (nike.apache.org: domain of braden@google.com designates 209.85.210.175 as permitted sender) Received: from [209.85.210.175] (HELO mail-iy0-f175.google.com) (209.85.210.175) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2012 15:28:03 +0000 Received: by iaky10 with SMTP id y10so2254763iak.6 for ; Thu, 06 Sep 2012 08:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :x-system-of-record; bh=j5y6UfJfB4W5U3wKtcZriAs+F9h6RMwmJEvQv5bUvTY=; b=RnJq9ajeGutSup8ASG/DUVazEntOEPfabxhOKdwc/x0qAtimlO/2P7wQFRxRy11XqL aNTuSZ5XpfkBuCuXJx3FlOkOA/+T3V/OkB5yvolfuwnJPVLvh2Wrg3OgZZqiAJbMzAtS +CwwhAy/bQjmsqMidRxZF41JirYzOnrhFtyBgoDZ01Ne0LyQTj99ls7GwvkyY7G5r/3n MX/b81FODPVFK5uoVY3sjB9yQOElSm2LzOXjInPcVa5nw+P1VTPFaaDUXcrqAQsmupV0 fpSSmbkFeJgu/+Sqq0JLgSNns4ZGF3rHwqx+D+SNHOQs6yTs8Icb2W3Z7GePezsuhXa7 7Plg== 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:date :x-google-sender-auth:message-id:subject:from:to:content-type :x-system-of-record:x-gm-message-state; bh=j5y6UfJfB4W5U3wKtcZriAs+F9h6RMwmJEvQv5bUvTY=; b=MCmcTIzeCdcfm+RThkCyED5ktOfiOQxo6CERv9iSRZpKUSdzth1FQyj3FDMJd5P9AE uNex80oWHzksUIxGvPhmEMxjUC68TT6VvjqodT/KyfYi6n6/HG1DBfak8OwjGVc58qY/ vQ/qjhHvJpCy+o6vWF9/T63eE2LYWaMeIpoCWniV9cltjL3O1EsKYW+afa8+qGmf2C7V o84FQLfn0GGBdqlhf2WMzCS39ztH/bo/KXEQk+nr5ONOpqcbsnbQN6KI4uUMfOmS929l Q0fGF7mm/BbNeJSNNULet+LFUqb0koo5kN+4gBAa7f0QMw82yQxLBwRyAe4S/KH3BlwA SUoA== Received: by 10.43.97.8 with SMTP id ci8mr2894499icc.28.1346945262830; Thu, 06 Sep 2012 08:27:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.43.97.8 with SMTP id ci8mr2894480icc.28.1346945262568; Thu, 06 Sep 2012 08:27:42 -0700 (PDT) Sender: braden@google.com Received: by 10.231.129.9 with HTTP; Thu, 6 Sep 2012 08:27:42 -0700 (PDT) In-Reply-To: References: Date: Thu, 6 Sep 2012 11:27:42 -0400 X-Google-Sender-Auth: 0jfhmfM48bO1wZlyDEkZCQNxfuI Message-ID: Subject: Re: Wiping plugins on navigation From: Braden Shepherdson To: callback-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=bcaec517ce76e845ca04c90a2137 X-System-Of-Record: true X-Gm-Message-State: ALoCoQl0os+MTF6nMFFgsExP0IDo05ObT7K6lLYZKEfGp7MC9xzAVI9qh+I9MFFbSZ0VvXzRnu1dhI9PJ74129P7MqeKsSIyjt9KEODL1tJ7qtHGIaekQ8727y4xelAE1TPvmQUz7r2DNbaCZ/b+HP9c3bWXmDDeEcx5wemBRVNOJr131zvNfAyVNMGaOYoKl4xVuy8mat7HgWusa1IoUscwejI7HzxxRw== --bcaec517ce76e845ca04c90a2137 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Repeating here a comment on the bug: Jimmy Jarvis added a comment - 05/Sep/12 23:02 - edited JSON-P uses a unique callback identifier, similar to the proposed fix above, and is far more reliable and easier to debug than reset with repeating IDs. It would be unfortunate overhead to have to reinitialize our native logic every time a page reloads. The app would become far less responsive, at least for us. If a plugin is a bunch of stubs, it's not an big deal as you say =96 however, if it is a longer running setup process --= -- I'd prefer ignoring unmatched callbacks. I agree sending the plugin a Reset or Terminate message would enable the plugin authors an opportunity to do proper cleanup on pending requests, but even if they do not, unique ID's (like JSON-P) are a better solution than repeating IDs. On Wed, Sep 5, 2012 at 9:33 PM, Andrew Grieve wrote: > Plugins could probably use static fields if they wanted to maintain some > state between page changes. I think it should be extremely rare to do so > though. e.g. For the platforms that implement their plugins in JS, is it > even possible to maintain state between page changes? > > One nice outcome of this is that it will make our mobile-spec pages less > likely to affect each other. > > > On Wed, Sep 5, 2012 at 6:59 PM, Brian LeRoux wrote: > > > Yes I do not refuting Cordova needs to work for both single page and > > multipage apps. Just saying there is a solution to this problem. ;P > > > > > > On Wed, Sep 5, 2012 at 3:49 PM, Jesse wrote: > > > Whether it is an edge case, or a common case, multi-page apps are a > > > reality, so we definitely need to notify plugins when the page is > > > changing. > > > I don't necessarily agree that the plugin should be destroyed and > > > recreated though, I can think of several cases where persistence woul= d > > > be nice to have. > > > > > > I also do not see this as a security issue. Security is already > > > governed by the white-list, so non-trusted pages cannot access device > > > functions. If a plugin needs additional security, then it should be > > > built into the plugin, and not the responsibility of the framework. > > > ... Thinking of a SuperCookie plugin which uses the domain of the > > > currently loaded page before deciding what to return, or something > > > similar. > > > > > > My 2 sense, > > > Jesse > > > > > > > > > On Wed, Sep 5, 2012 at 3:30 PM, Bryce Curtis > > wrote: > > >> Sometimes multi-page apps are needed or you navigate from your app t= o > > >> another page. One bug we ran into was that callback ids are reused > > >> when loading a new page. So, a plugin trying to send data back to t= he > > >> original page could be calling a recycled plugin with erroneous data= . > > >> In addition to the bugs, there is also a security issue with a > > >> subsequent page being able to access a plugin that was used in a > > >> previous page. > > >> > > >> The app/page lifecycle events are propagated to the plugins, and the > > >> plugins are destroyed when loading a new page. However, looking at > > >> the code, it appears this may be broken now. (At least for Android)= . > > >> > > >> On Wed, Sep 5, 2012 at 3:40 PM, Braden Shepherdson < > braden@chromium.org> > > wrote: > > >>> Sure, and I'm a fan of single-page apps (I do work for Google, afte= r > > >>> all...), but this causes very chaotic, hard-to-track bugs, so it > makes > > >>> sense to be robust over a refresh/navigation. > > >>> > > >>> > > >>> On Wed, Sep 5, 2012 at 5:25 PM, Brian LeRoux wrote: > > >>> > > >>>> One thing to note, we tend to advise ppl author single page web ap= ps > > >>>> which makes state visibility change an app logic concern (and avoi= d > > >>>> this issue from manifesting). Generally, we can say a page refresh > is > > >>>> not a great user experience in apps. > > >>>> > > >>>> On Wed, Sep 5, 2012 at 1:15 PM, Braden Shepherdson < > > braden@chromium.org> > > >>>> wrote: > > >>>> > This is intended as a continuation of the discussion started in > > >>>> > https://issues.apache.org/jira/browse/CB-1318 . > > >>>> > > > >>>> > The bug in question is one where one page starts a long native > side > > >>>> action > > >>>> > such as a network call. Then the user navigates the app to anoth= er > > page. > > >>>> > When the long action completes, the call returns and the > appropriate > > >>>> > Javascript callback is looked up and called. > > >>>> > > > >>>> > However when the page is navigated, the counter that provides > > supposedly > > >>>> > unique names for callbacks is reset, allowing a callback on the > new > > page > > >>>> to > > >>>> > have the same name as the callback from the old page. It then ge= ts > > called > > >>>> > incorrectly, potentially introducing weird and transient bugs. > > >>>> > > > >>>> > The proposed solution is to do the following on navigation: > > >>>> > - Call a destroy() call on all plugins, which by default does > > nothing. > > >>>> This > > >>>> > allows the plugins a chance to cancel any outstanding network > > requests or > > >>>> > do any other cleanup work. > > >>>> > - Delete the plugin instance and recreate it. > > >>>> > > > >>>> > In the bug I also said one step would be to wipe the callback > table > > in > > >>>> the > > >>>> > Javascript, but that isn't necessary since it would have been > wiped > > by > > >>>> the > > >>>> > navigation anyway. > > >>>> > > > >>>> > This issue is cross-platform-ish. It (probably) doesn't apply to > > >>>> web-based > > >>>> > platforms like WebOS or Bada, because the plugins are Javascript > > shims > > >>>> > rather than native code, and are wiped on navigation like any > other > > >>>> > Javascript. However this issue does exist on at least Android an= d > > iOS, > > >>>> and > > >>>> > probably a few others as well. > > >>>> > > > >>>> > I'm proposing to implement the solution outlined above on Androi= d > > and > > >>>> iOS. > > >>>> > I don't have the devices or environment to do any other platform= s, > > nor > > >>>> am I > > >>>> > sure which are necessary. The maintainers of other platforms wil= l > > have to > > >>>> > consider this problem for their platform. I would also update th= e > > core > > >>>> > plugins to define a destroy() method if they have relevant > cleanups > > to > > >>>> make. > > >>>> > > > >>>> > Thoughts on the approach, things I'm missing? > > >>>> > > > >>>> > Braden > > >>>> > > > > > > > > > > > > -- > > > @purplecabbage > > > risingj.com > > > --bcaec517ce76e845ca04c90a2137--