DanReyLop has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/247876

Change subject: Fix infinite loop in the webview's widen images logic
......................................................................

Fix infinite loop in the webview's widen images logic

In the webview's Javascript code, the images from a page are stretched to
fit in the device's screen. When widening an image, a image URL of greater
resolution can be used instead to fit better with the new computed dimensions.
With this change, we make sure that after this logic takes place, it won't be 
called
again for the same image, which was provoking an infinite loop causing high
CPU usage.

Bug: T109983
Change-Id: I759297334cb7e0c32dc00cd71b300c9783ebf2af
---
M app/src/main/assets/bundle.js
M www/js/transforms/widenImages.js
2 files changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/76/247876/1

diff --git a/app/src/main/assets/bundle.js b/app/src/main/assets/bundle.js
index e5be35b..e54e379 100644
--- a/app/src/main/assets/bundle.js
+++ b/app/src/main/assets/bundle.js
@@ -1235,6 +1235,7 @@
 
 function maybeWidenImage() {
     var image = this;
+    image.removeEventListener('load', maybeWidenImage, false);
     if (shouldWidenImage(image)) {
         widenImage(image);
     }
diff --git a/www/js/transforms/widenImages.js b/www/js/transforms/widenImages.js
index 9871737..319cacb 100644
--- a/www/js/transforms/widenImages.js
+++ b/www/js/transforms/widenImages.js
@@ -92,6 +92,7 @@
 
 function maybeWidenImage() {
     var image = this;
+    image.removeEventListener('load', maybeWidenImage, false);
     if (shouldWidenImage(image)) {
         widenImage(image);
     }

-- 
To view, visit https://gerrit.wikimedia.org/r/247876
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I759297334cb7e0c32dc00cd71b300c9783ebf2af
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: DanReyLop <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to