Browse Source

fix: gifs and videos on the message feed now pause when offscreen, conserving cpu usage

Paul Frazee 4 years ago
parent
commit
f929c75311
3 changed files with 21 additions and 14 deletions
  1. 14
    13
      package.json
  2. 6
    0
      ui/lib/com/message-feed.js
  3. 1
    1
      ui/lib/markdown.js

+ 14
- 13
package.json View File

@@ -31,35 +31,36 @@
31 31
     "tape": "~3.0.0"
32 32
   },
33 33
   "dependencies": {
34
-    "multiblob": "^1.5.0",
35
-    "multicb": "^1.1.0",
36
-    "muxrpc": "^6.1.1",
37
-    "pull-ipc": "0.0.1",
38
-    "pull-pushable": "^1.1.4",
39
-    "pull-stream": "^2.27.0",
40
-    "scuttlebot": "~7.3.0",
41
-    "ssb-config": "^1.0.3",
42
-    "ssb-keys": "^4.0.3",
43
-    "stream-to-pull-stream": "^1.6.1",
44 34
     "blob-to-buffer": "^1.2.3",
45 35
     "emoji-named-characters": "^1.0.1",
46 36
     "hyperscript": "~1.4.6",
47 37
     "mime-types": "^2.1.3",
38
+    "multiblob": "^1.5.0",
39
+    "multicb": "^1.1.0",
40
+    "muxrpc": "^6.1.1",
48 41
     "nicedate": "~0.0.0",
49 42
     "observable": "^2.1.3",
50 43
     "once": "~1.3.1",
44
+    "pause-offscreen": "^1.0.0",
51 45
     "phoenix-router": "~1.0.0",
52 46
     "published-working-tree": "~0.0.0",
53 47
     "pull-cat": "^1.1.7",
48
+    "pull-ipc": "0.0.1",
49
+    "pull-level": "~1.2.0",
54 50
     "pull-merge": "~1.0.2",
51
+    "pull-notify": "0.0.0",
55 52
     "pull-paramap": "^1.1.3",
53
+    "pull-pushable": "^1.1.4",
54
+    "pull-stream": "^2.27.0",
56 55
     "pull-stream-to-stream": "~1.3.0",
56
+    "scuttlebot": "~7.3.0",
57
+    "ssb-config": "^1.0.3",
58
+    "ssb-keys": "^4.0.3",
57 59
     "ssb-marked": "~0.5.0",
58 60
     "ssb-msg-schemas": "~5.0.0",
59 61
     "ssb-msgs": "~5.0.0",
60 62
     "ssb-ref": "~2.2.0",
61
-    "suggest-box": "~1.1.6",
62
-    "pull-level": "~1.2.0",
63
-    "pull-notify": "0.0.0"
63
+    "stream-to-pull-stream": "^1.6.1",
64
+    "suggest-box": "~1.1.6"
64 65
   }
65 66
 }

+ 6
- 0
ui/lib/com/message-feed.js View File

@@ -3,10 +3,12 @@ var h = require('hyperscript')
3 3
 var mlib = require('ssb-msgs')
4 4
 var pull = require('pull-stream')
5 5
 var multicb = require('multicb')
6
+var pauser = require('pause-offscreen')
6 7
 var app = require('../app')
7 8
 var com = require('../com')
8 9
 var u = require('../util')
9 10
 
11
+
10 12
 module.exports = function (opts) {
11 13
   opts = opts || {}
12 14
   var botcursor
@@ -36,6 +38,10 @@ module.exports = function (opts) {
36 38
   fetchBottom(function (n) {
37 39
     if (opts.onempty && n === 0)
38 40
       opts.onempty(feedEl)
41
+
42
+    // add offscreen pausing
43
+    var unlistenPauser = pauser(containerEl)
44
+    ui.onTeardown(unlistenPauser)
39 45
   })
40 46
 
41 47
   function fetchBottom (cb) {

+ 1
- 1
ui/lib/markdown.js View File

@@ -72,7 +72,7 @@ renderer.image  = function (href, title, text) {
72 72
   href = href.replace(/^&/, '&')
73 73
   if (ssbref.isLink(href)) {
74 74
     if ((''+text).indexOf('.webm') >= 0) {
75
-      var out = '<video autoplay=1 loop=1 muted=1 src="http://localhost:7777/' + href + '?fallback=video" alt="' + text + '"'
75
+      var out = '<video loop=1 muted=1 src="http://localhost:7777/' + href + '?fallback=video" alt="' + text + '"'
76 76
       if (title) {
77 77
         out += ' title="' + title + '"'
78 78
       }

Loading…
Cancel
Save