thomasandersen / gfycat-companion-for-firefox

https://addons.mozilla.org/en-US/firefox/addon/gfycat-companion/
MIT License
7 stars 3 forks source link

Fix null pointer exception processing result of "getTotalBandwidthSavedInMB" #11

Open laurence-myers opened 10 years ago

laurence-myers commented 10 years ago

This is to resolve Issue #10.

In "initInfoPanel", there is a call to "getTotalBandwidthSavedInMB". This function can return null, for example if there is an exception parsing a preference to a float. However, the invoking code always assumed a non-null result, and was calling ".toFixed(2)" on the result. This has the upshot of preventing the video from actually being displayed.

laurence-myers commented 10 years ago

I'm not sure, but is the null value caused because the preference "gfycatCompanion.bandwidthSavedBytes" does not exist until gfycat writes at least one value to it, but on a fresh installation this preference won't exist, and because of this error it can never finish processing the video and hence never writes a value to the preference?

bakkerthehacker commented 10 years ago

can this get merged in and built? im having the same thing as #10 and I would like to see if this fixes it

whispy commented 10 years ago

I agree with @bakkerthehacker . Right now, the add-on is unusable.

laurence-myers commented 10 years ago

@bakkerthehacker @whispy Can you please try this workaround?

whispy commented 10 years ago

@laurence-myers,

Creating the SavedBytes string and entering a value of 0 did not work.

However, I'm looking at the source of the extension's page, and I see:

<video controls="true" loop="true" autoplay="true" style="display:none" width="480">
  <source src="http://zippy.gfycat.com/PopularWearyChinchilla.webm" type="video/webm">
  <source src="http://zippy.gfycat.com/PopularWearyChinchilla.mp4" type="video/mp4">
</video>

If I remove the display:none, then the video is shown and plays perfectly fine. I think somehow the addon is just not removing display:none when the video is loaded.

Should I create a new issue for this?

EDIT: Ah. Just perused the first two comments and I guess this is a side effect of the issue with the SavedBytes string?

whispy commented 10 years ago

FIX! @laurence-myers @bakkerthehacker

Okay, I manually changed the extensions.gfycatCompanion.bandwidthSavedBytes value to 1 (instead of 0). This results in the extension working properly — the video displays!

So, for some reason, it seems that the value of 0 doesn't allow the extension to move forward properly, but values larger than 0 do.

The extension appears to change the value itself when I load a .gif. For example, right now it has set itself to: 2014-09-08_15-32-03