Re: [xmpp] multi-tabs (was: Re: Consensus Call : Adoption of draft-moffitt-xmpp-over-websocket)

Lance Stout <lancestout@gmail.com> Wed, 21 August 2013 17:20 UTC

Return-Path: <lancestout@gmail.com>
X-Original-To: xmpp@ietfa.amsl.com
Delivered-To: xmpp@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6AD4F11E83C7 for <xmpp@ietfa.amsl.com>; Wed, 21 Aug 2013 10:20:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7LZcf-uUrtvZ for <xmpp@ietfa.amsl.com>; Wed, 21 Aug 2013 10:20:23 -0700 (PDT)
Received: from mail-pb0-x230.google.com (mail-pb0-x230.google.com [IPv6:2607:f8b0:400e:c01::230]) by ietfa.amsl.com (Postfix) with ESMTP id B328211E83AF for <xmpp@ietf.org>; Wed, 21 Aug 2013 10:20:16 -0700 (PDT)
Received: by mail-pb0-f48.google.com with SMTP id ma3so652705pbc.35 for <xmpp@ietf.org>; Wed, 21 Aug 2013 10:20:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:message-id:mime-version:subject:date:references :to:in-reply-to; bh=1x/6YaJWvXQKx39FqWWO67sdErhn3xQYboUgOdLartY=; b=t5l/XzUKnGCSvYNyFplNsOOw55y2FwbBIiNdiVxolYcRSsWQSGw1F/u5LVU8/GUGJj Jp0vuci1k4KpUeJ9TvMcAL1Fbq3Hbt3pEC6HmWVPFE2VeQUsCnt1YMBb4g20w6tJH+2P ZrzfnlXD6oG97Szplyuc+o77Gzyl+HFa5+o4axAshRimN1eEazwIloGEEZWEuM9V6DPb 0CT+NNZaBzyDV6N1ktKF4SKcvP+NnShZP71bIBXcK1LSwYsoYz/KZxD46gVYqQxdZSOB yucxLtZQzDHv/9RzmkpFPrvP5LiE/NQspcv/l1MU2GH6yfU8UD37binDkM4bCR/8vmP2 E5Lg==
X-Received: by 10.66.191.137 with SMTP id gy9mr793874pac.147.1377105616441; Wed, 21 Aug 2013 10:20:16 -0700 (PDT)
Received: from [10.0.2.197] (71-84-176-17.dhcp.mdfd.or.charter.com. [71.84.176.17]) by mx.google.com with ESMTPSA id s5sm9506317pbo.38.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 10:20:15 -0700 (PDT)
From: Lance Stout <lancestout@gmail.com>
Content-Type: multipart/signed; boundary="Apple-Mail=_ADAC2E88-0032-4889-929C-8BD0BE15762F"; protocol="application/pkcs7-signature"; micalg="sha1"
Message-Id: <07C838D0-5A6D-4A0B-A742-D71A922BC8CE@gmail.com>
Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\))
Date: Wed, 21 Aug 2013 10:20:13 -0700
References: <03C5234F-7DEE-4EFD-AFDF-C2CBF53BD099@nostrum.com> <5214B6FB.9030707@ik.nu> <297182D3-2EB6-47C1-94A2-EC5536585EFE@erlang-solutions.com> <5214E834.8090302@stpeter.im>
To: xmpp@ietf.org
In-Reply-To: <5214E834.8090302@stpeter.im>
X-Mailer: Apple Mail (2.1508)
Subject: Re: [xmpp] multi-tabs (was: Re: Consensus Call : Adoption of draft-moffitt-xmpp-over-websocket)
X-BeenThere: xmpp@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: XMPP Working Group <xmpp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/xmpp>, <mailto:xmpp-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/xmpp>
List-Post: <mailto:xmpp@ietf.org>
List-Help: <mailto:xmpp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/xmpp>, <mailto:xmpp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 21 Aug 2013 17:20:25 -0000

> > If are talking about websockets, how are you dealing with multiple
> > tabs opened by the user?
> 
> That's a difficult issue and it probably isn't even something we can
> solve in the XMPP Over WebSocket specification. But discussion is
> welcome (I've branched off a new thread for that purpose).


Right, any solution for this problem would likely be applicable across
all "* over WebSocket" use cases.


Having implemented XMPP over WebSockets in the browser, here's what I've
learned so far:


1. Ignoring tabs at the moment, just navigating to a new page can be
   handled very quickly using Stream Management (XEP-0198) resumption
   if the ack data is preserved in something like localStorage.

2. Not giving special consideration to tab connections works remarkably
   well when using  MAM (XEP-0313) and Message Carbons (XEP-0280). The only 
   downside is that you have to do the entire stream startup unlike when
   doing session resumption. So the full
   
      a) auth
      b) bind
      c) roster (skippable if you use roster versioning)
      d) inbound presence
      e) inbound pep

   That said, if you are caching data locally for the origin domain (using
   IndexedDB, etc), then you can use that to bootstrap the UI while the
   initial data streams in, much like you would for session resumption.

3. If you really don't want a new connection per tab, things are very 
   tricky at the moment. Running a WebSocket connection as a Shared Web
   Worker process doesn't appear to work, nor can a shared worker access
   the DOM methods needed to parse XML.

   But you can use them or window.postMessage to broadcast information from
   the tab that has the XMPP connection to other tabs. Of course if the tab
   with the connection is closed, things get fun very quickly :)



-- Lance