New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swicthing screen causes bug on Firebase #1510

Open
GOTFire opened this Issue Jan 7, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@GOTFire
Copy link

GOTFire commented Jan 7, 2019

I currently using firebase on my project and my app already installed more than 1k so when i looking statics about usage of my firebase plan there is somethink wrong with it.

I used 12,9GB!
My app use firebase for download questions and question size is 200kb and my firebase usage is 12.9 Wow

There is a bug and i find it.

I use Firebase database profiller tool to check database.There is no problem with my blocks.But when i switching screens its do 2x get operation for each screen switch.

When switching to other screen and if the other screen use firebase.My app try get "/" and "projectbucket" from firebase.

Here database profiller result.(its dummy database result)

https://i.hizliresim.com/Rr3Gbn.png

Bandwidth Report

NOTE: The numbers reported here are only estimates of the data payloads from read operations. They are NOT a valid measure of your bandwidth bill.

Downloaded Bytes

┌────────────┬─────────┬───────┬───────────┐
│ Path │ Total │ Count │ Average │
├────────────┼─────────┼───────┼───────────┤
│ / │ 2.94 MB │ 5 │ 587.33 kB │
├────────────┼─────────┼───────┼───────────┤
│ /Firebases │ 0 B │ 5 │ 0 B │
└────────────┴─────────┴───────┴───────────┘

Uploaded Bytes

┌──────┬───────┬───────┬─────────┐
│ Path │ Total │ Count │ Average │
└──────┴───────┴───────┴─────────┘

Unindexed Queries

┌──────┬───────┬───────┐
│ Path │ Index │ Count │
└──────┴───────┴───────┘

I get this result when switching between screens. Firebase is projectbucket name

So as you can see there is 2x get operation(I swithed screen 5x).And app trying get all database.My database total size is 1MB and my daily usage 400MB but my question size is 200 KB.So this bug causes hight download usage.

Please fix it :) I m going exceed my free plan again 👍

Here my test aia.
https://yadi.sk/d/cHt4_9olTyXBAQ

You can seee same think with your own Firebase account and database profiller

@ewpatton

This comment has been minimized.

Copy link
Member

ewpatton commented Jan 7, 2019

I'm not sure that this is a bug in App Inventor. The Firebase library will attempt to retrieve existing keys that have already been requested when it connects to the DB. If you're requesting the tag from the DB, then you will get 2 copies (one automatic from Firebase on start and your request from the blocks). You might want to redesign your app so that you also use a TinyDB to check if you have already downloaded the database, and if you haven't, manually get the contents from Firebase. This will cause it to be registered for future updates (and automatic recall on restart). If your flag says you've already downloaded the contents, do nothing.

Try changing your app to use the above logic and see if you still get the double counting.

@GOTFire

This comment has been minimized.

Copy link
Author

GOTFire commented Jan 7, 2019

Nope ,you dont understand me.I dont need somethink like tinydb.Its just test project.I dont use any get or any other firebase block.I created this project for hunt bug.These block just added to fill my empty test project.There is a problem with Firebase.When opened x screen and if x screen has firebase its try get all data by itself.I dont use any get block when screen init or clicked button.I added buttons for change screens.

When opening screen its download all database again and again if user keep switching screens.So if database size is 1MB and if 100 switch operation happen.App download 400MB for each day.But its not correct because.I hope you understand what ı m talking about.

Problem is : If firebase added to any screen and user swtich to this screen firebase try get all database when user opened screen.I dont call any get or any other think.Maybe its about datachanged block but ı dont use it.

@GOTFire

This comment has been minimized.

Copy link
Author

GOTFire commented Jan 24, 2019

I succesfully downgrade my download with the new Kodular update.With the New update i can change firebase url and bucket. So i changed firebase url to firebaseurl/dummyvalue and added change firebase url to screen init block. With this litle trick firebase do not download all of my database.

Its try get dummyvalue and dummyvalue/projectbucket. This tag is empty so its not download anythink when user switching screens.Its keep increase my download usage (get request, ssl encoding..) but its not get all of my database so this trick downgrade my usage.

If App Inventor team add firebase url to block side anyone can use this

Here result

https://yadi.sk/i/epSTP0IDceBruw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment