mikehostetler / amplify

AmplifyJS
http://amplifyjs.com
GNU General Public License v2.0
1.44k stars 144 forks source link

Bug in store retrieval after hitting back button on Android #78

Closed jrsconfitto closed 11 years ago

jrsconfitto commented 11 years ago

It seems that amplify.store won't correctly retrieve stored values after being navigated to from the back button. On the first load of the page, i'm able to store and retrieve values, but if i navigate somewhere from that page, and then hit the back button to go back in history, neither storing nor retrieving work.

i've coded up an example that you can test yourself on bl.ocks.org and you can view the code in the gist.

The instructions for reproduction are being rendered janky by blocks so i'm listing them here as well:

  1. Use Android Froyo, Gingerbread, or Jelly Bean. i tested all of them and see the same issue.
  2. Click the text below to store a value. You can retrieve it by clicking on the retrieve text to see it worked
  3. navigate to another page, here's Google. Or you can navigate to "jugglingnutcase's" blocks at the bottom of the page if the google link doesn't render in the phone.
  4. Go back via your back button. The page may not look loaded, it might be blocks or Android or something. It will still work!
  5. Click in the area to retrieve values and you should see 'undefined'. Storing values and retrieving them now doesn't work.
jrsconfitto commented 11 years ago

i think this is similar to the bug mentioned in #61.

jrsconfitto commented 11 years ago

Sadly, i'm trying to release something soon and don't have time to do a proper PR :snail:

i'll try to put one together once i'm past this release, but no promises. Sorry :frowning:

jrsconfitto commented 11 years ago

Also, an issue i've found that may be helpful in solving this is that storage, in this line, is undefined under these circumstances.

jrsconfitto commented 11 years ago

Checked in on this and realized the demo no longer worked because i was directly linking to the raw on github, but then it moved (completely reasonable).

i downloaded 1.1.0 of amplify.store.js and included that in the gist. The repro gist should work now.

jakerella commented 11 years ago

Put this in a jsbin: http://jsbin.com/igohir/1 (no real reason, other than editability and clonability). I am unable to replicate (that is, it works) in the stock browser on an virtual device running Android 4.1.2 or 2.2, or my actual device, which is running 2.3.4. The jsbin also works in Chrome and Firefox on Linux, and all major browsers on Windows XP (including Safari for windows.

Sorry, but I simply can't replicate this one! Take a look at the jsbin and let me know if I'm missing something, but I copied your block html and just made slight html tweaks, no functionality changes.

jrsconfitto commented 11 years ago

Hm... The jsbin works fine for my JellyBean emulator. It still doesn't work in blocks, but that may just be the way blocks is. Thanks for checking this out.