Skip to content
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

HiveError: Adapter not registered? #4807

Closed
g123k opened this issue Nov 16, 2023 · 45 comments
Closed

HiveError: Adapter not registered? #4807

g123k opened this issue Nov 16, 2023 · 45 comments

Comments

@g123k
Copy link
Collaborator

g123k commented Nov 16, 2023

Hi everyone,

This is a bug noticed by @teolemon when he opens the app:

Screenshot_20231116-112207

Fatal Error: HiveError: Cannot read, unknown typeld: 33. Did you forget to register an adapter?

I don't know where the error is exactly and there is no issue on Sentry.

@monsieurtanuki
Copy link
Contributor

@teolemon Could it be that you have a sort of dev app not really cleanly installed, that would still use old code - like an app reload in Android Studio?

@rodrigost23
Copy link

I'm having this issue with the app installed from the Play Store.

@monsieurtanuki
Copy link
Contributor

@rodrigost23 I've just downloaded the app from scratch from the Google Play Store and didn't experience this HiveError. Can you please be more verbose about "your" error? (store, os, when in the app run, new install or upgrade...)

@rodrigost23
Copy link

It happens when opening the app. I have tried force-closing it and opening again and it just shows this white screen with the message.

I'm on Android 13 (OneUI 5.1.1), app version 4.11.0 installed from the Play Store.

It used to work before, but it's been a while since I haven't used the app, so I don't know if this error was caused by an update.

Screenshot_20231118_122515.jpg

@M123-dev
Copy link
Member

I have the same and as far as I know Stefan and another person on Slack aswell. Deleting the storage of the app should fix it. But that's not something we should rely on

@denseishin
Copy link

I have the same issue. On Android 11 OneUI 3.1 App Version 4.11

@monsieurtanuki
Copy link
Contributor

I've had a look at our code around hive, and the only recent change (2 weeks ago) I noticed was that a hive box was removed (in the "old TODOs" PR).
We don't use this hive box anymore - the dart file was even removed - but perhaps in some conditions it's not a good thing not to init existing boxes, even if not used anymore. I was not able to reproduce the error on my emulator though.
And perhaps that PR isn't even part of the latest release.

@fgouget
Copy link

fgouget commented Nov 18, 2023

I have the exactly same error on a Galaxy S7 (SM-G930F) running Android 8.0.0. This started today and the app was auto upgraded to 4.11.0 yesterday.

Based on the comments in this bug I first tried deleting the app's cache but it still crashed on startup. So I deleted the app's data and now it works again.

@M123-dev
Copy link
Member

Quick question, is everyone who had the problem in the beta channel

@teolemon
Copy link
Member

Yes,it's an internal only issue

@denseishin
Copy link

Quick question, is everyone who had the problem in the beta channel

No. I am a regular end user who downloaded it from the play store

@teolemon
Copy link
Member

😱 @denseishin Can you confirm your build number by going to Settings >> FAQ >> About this App ?

@denseishin
Copy link

denseishin commented Nov 19, 2023

😱 @denseishin Can you confirm your build number by going to Settings >> FAQ >> About this App ?

I can't access any in-app menu (just like rodrigost23)

@M123-dev
Copy link
Member

Just read through this long issue of people having a problem setting hive up, but found this comment isar/hive#269 (comment)

Maybe it's not as simple as removing a Box but calling mymodel.deleteFromDisk() first

@teolemon
Copy link
Member

@denseishin sorry, my brain wasn't working. Can you access it from Android Settings, Apps, OFF, or by longpressing the Open Food Facts icon ?

@denseishin
Copy link

@teolemon I can't see a build number, only a version number (4.11.0)

@monsieurtanuki
Copy link
Contributor

"good" news: if I get the 4.11.0 apk from https://github.com/openfoodfacts/smooth-app/releases, I can reproduce the crash (it even crashes my emulator). The first time it's when I get my first product (somehow first time a product is inserted in the database / the first time a product is inserted in history). Then it's just after the splash screen + onboarding.

I recommend an emergency 4.12.0 release today, given that I've never experienced that on regular dev.

@rodrigost23
Copy link

rodrigost23 commented Nov 19, 2023

@M123-dev:

Quick question, is everyone who had the problem in the beta channel

I'm not. I downloaded the app from the Play Store. And as I said, I'm on 4.11.0

@teolemon:

Yes,it's an internal only issue

Well, it's happening in 4.11.0 from Play Store.

Screenshot_20231119_065922_Settings.jpg

@teolemon
Copy link
Member

I don't understand how 4.11.0 can be crashing (It's old 4.11.0 (2023-10-26), and I believe I used it without any hiccups.)
@monsieurtanuki Does the current version fix it without requiring data wipe ? I had to wipe my data.
I'm prepping the release as we speak.

@teolemon
Copy link
Member

I have a new build uploaded to internal, ready to promote to main.
I'm going to quickly reproduce the issue, to check it's an invisible fix.

@M123-dev
Copy link
Member

@teolemon feel free to ping me in slack when it's in internal. I didn't clean my storage to be able to test this (been using the F-Droid variant as alternative)

@monsieurtanuki
Copy link
Contributor

Does the current version fix it without requiring data wipe ?

@teolemon Could not test because I needed the same "level" of app (e.g. release vs debug) and I didn't manage to create a release apk for some gradle BS reason (flutter build apk -t lib/entrypoints/android/main_google_play.dart).
Is there a link to your apk?

@teolemon
Copy link
Member

@teolemon
Copy link
Member

under playstore review

@g123k
Copy link
Collaborator Author

g123k commented Nov 19, 2023

Does the current version fix it without requiring data wipe ?

@teolemon Could not test because I needed the same "level" of app (e.g. release vs debug) and I didn't manage to create a release apk for some gradle BS reason (flutter build apk -t lib/entrypoints/android/main_google_play.dart). Is there a link to your apk?

I don't have access to my computer right now, but you can use the profile mode.
It's similar to release, but provides some logs.

flutter run --profile …

@monsieurtanuki
Copy link
Contributor

Cannot find @teolemon's 4.12.0 release, and cannot run flutter --release because of the same gradle BS.
Had no problem with my device. My goal now is to be able to build or run as --release for my emulator.
Currently upgrading my Android Studio version, with a Giraffe I'll have a better view. Haha.

@teolemon
Copy link
Member

My version of Android hides build number 🤯
I can't get the update yet which is supposedly available, and it still crashes.
Need to be AFK for some time, taking my laptop with me.

@monsieurtanuki
Copy link
Contributor

Capture d’écran 2023-11-19 à 14 56 33

@teolemon
Copy link
Member

I'm working under the assumption that I have the latest build, and that it is not fixed @g123k @monsieurtanuki @M123-dev
Screenshot_20231119-150347.png

@monsieurtanuki
Copy link
Contributor

@teolemon If so I would stop now the upgrade to the current latest version 4.11 on Google Play.
Meanwhile I'll have a look at each PR of 4.11, possibly today. hive itself hasn't changed in the last 16 months. Our code related to hive hasn't changed much either.
Perhaps some dependency?

@teolemon
Copy link
Member

teolemon commented Nov 19, 2023

I'm doing damage control by email and in play store comments, but no way to rollback anymore.

@teolemon
Copy link
Member

teolemon commented Nov 19, 2023

@g123k @monsieurtanuki shouldn't we try to rollback to old code with a new version?

@monsieurtanuki
Copy link
Contributor

I'm trying to check if 4.9.1 is safe.

@g123k
Copy link
Collaborator Author

g123k commented Nov 19, 2023

I have a clue on the issue: an Adapter is missing in the code.
We have _BarcodeListAdapter with id = 0 and _ProductAdapter with id = 2.
Internally Hive adds 32 to all ids, meaning 32 and 34 in our case.
So the question is: where is 33? (or 1 in the code)

Code to find in the history: final int typeId = 1;

--

Got it!

In August, _ProductAdapter had the id 1!
Screenshot 2023-11-19 at 19 02 31

We have to find why it changed to 2

Edit: it was in the file dao_hive_product.dart, but it doesn't exist anymore.

@g123k
Copy link
Collaborator Author

g123k commented Nov 19, 2023

This is the faulty PR: #4758
Any idea why you removed this file @monsieurtanuki?

I think a revert on this PR will be enough

@monsieurtanuki
Copy link
Contributor

monsieurtanuki commented Nov 19, 2023

Any idea why you removed this file @monsieurtanuki?

We don't use it anymore [edit: // TODO(monsieurtanuki): remove when old enough (today is 2022-06-16)].
And it's not part of 4.11 anyway AFAIK.

@monsieurtanuki
Copy link
Contributor

Internally Hive adds 32 to all ids

What a brillant idea they have! So much easier for debugging.

@g123k That said, I can just add a useless dao hive. Working on it.

@teolemon
Copy link
Member

The update fixes it in internal. Going to promote to stable. @monsieurtanuki @g123k @M123-dev

@g123k
Copy link
Collaborator Author

g123k commented Nov 19, 2023

Please wait for some confirmations that the change is correct first

@M123-dev
Copy link
Member

Works for me 👍🏻

@monsieurtanuki
Copy link
Contributor

I was trying to reproduce the crash first but I can't anymore.
Can't be helpful regarding tests.

@monsieurtanuki
Copy link
Contributor

The allegedly faulty PR is 2 weeks old:
Capture d’écran 2023-11-19 à 20 29 18

The 4.11.0 release is 3 weeks old:
Capture d’écran 2023-11-19 à 20 29 36

WTF?

@teolemon
Copy link
Member

teolemon commented Nov 19, 2023

  • I did refresh on the playstore this week without changing the version name. I was under the wrong impression that I had tested the build in internal. My Bad.
  • That said, I was much more at ease when we had regular internal releases. I keep forgetting to refresh manually internal, which is essential to spot issues early (and not just rely on ½ people)

@monsieurtanuki
Copy link
Contributor

without changing the version name

I would not recommend that. That makes understanding the behavior of the app very difficult, especially if you're the only one that knows what you did.

I was under the wrong impression that I had tested the build in internal. My Bad.

I suggest a new unit test, with data inserted to the product and product list table.
Besides - if technically possible - we would be better off with tests of an app installed from scratch and of an app upgraded.

That said, I was much more at ease when we had regular internal releases. I keep forgetting to refresh manually internal, which is essential to spot issues early (and not just rely on ½ people)

Regular releases make sense.

@g123k
Copy link
Collaborator Author

g123k commented Nov 20, 2023

We have the confirmation that the fix is OK on Slack.
For the release process, please open a dedicated issue/discussion (but there were already some guidelines 🙄).

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

No branches or pull requests

7 participants