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

Weird issues #4575

Closed
g123k opened this issue Aug 21, 2023 · 7 comments · Fixed by #4591
Closed

Weird issues #4575

g123k opened this issue Aug 21, 2023 · 7 comments · Fixed by #4591
Assignees
Labels
🐛 bug Something isn't working

Comments

@g123k
Copy link
Collaborator

g123k commented Aug 21, 2023

As reported by @saiprasad-patil, he got two issues:

  • One with the Nutrition facts page not being able to be opened:
E/flutter (  517): #3      NutritionPageLoaded.showNutritionPage (package:smooth_app/pages/product/nutrition_page_loaded.dart:55:39)
E/flutter (  517): <asynchronous suspension>
E/flutter (  517): #4      _EditProductPageState.build.<anonymous closure> (package:smooth_app/pages/product/edit_product_page.dart:199:21)
E/flutter (  517): <asynchronous suspension>
E/flutter (  517):
I/ViewRootImpl@f52d2dd[MainActivity](  517): ViewPostIme pointer 0
I/ViewRootImpl@f52d2dd[MainActivity](  517): ViewPostIme pointer 1
E/flutter (  517): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter (  517): #0      OrderedNutrientsCache._getKey (package:smooth_app/pages/product/ordered_nutrients_cache.dart:67:67)
E/flutter (  517): #1      OrderedNutrientsCache._get (package:smooth_app/pages/product/ordered_nutrients_cache.dart:39:35)
E/flutter (  517): #2      OrderedNutrientsCache.getCache (package:smooth_app/pages/product/ordered_nutrients_cache.dart:24:43)
E/flutter (  517): #3      NutritionPageLoaded.showNutritionPage (package:smooth_app/pages/product/nutrition_page_loaded.dart:55:39)
E/flutter (  517): <asynchronous suspension>
E/flutter (  517): #4      _EditProductPageState.build.<anonymous closure> (package:smooth_app/pages/product/edit_product_page.dart:199:21)
E/flutter (  517): <asynchronous suspension>
E/flutter (  517):
I/ViewRootImpl@f52d2dd[MainActivity](  517): ViewPostIme pointer 0
I/ViewRootImpl@f52d2dd[MainActivity](  517): ViewPostIme pointer 1
E/flutter (  517): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter (  517): #0      OrderedNutrientsCache._getKey (package:smooth_app/pages/product/ordered_nutrients_cache.dart:67:67)
E/flutter (  517): #1      OrderedNutrientsCache._get (package:smooth_app/pages/product/ordered_nutrients_cache.dart:39:35)
E/flutter (  517): #2      OrderedNutrientsCache.getCache (package:smooth_app/pages/product/ordered_nutrients_cache.dart:24:43)
E/flutter (  517): #3      NutritionPageLoaded.showNutritionPage (package:smooth_app/pages/product/nutrition_page_loaded.dart:55:39)
E/flutter (  517): <asynchronous suspension>
E/flutter (  517): #4      _EditProductPageState.build.<anonymous closure> (package:smooth_app/pages/product/edit_product_page.dart:199:21)
  • And the second one with packaging:
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _TypeError was thrown building Builder:
Null check operator used on a null value
The relevant error-causing widget was:
  Navigator-[LabeledGlobalKey<NavigatorState>#eebf6]
  Navigator:file:///C:/Users/saipr/AppData/Local/Pub/Cache/hosted/pub.dev/go_router-7.0.2/lib/src/builder.dart:246:12
When the exception was thrown, this was the stack:
#0      ProductQuery.getLocaleString (package:smooth_app/query/product_query.dart:78:22)
#1      SimpleInputNumberField.getNumberFormat (package:smooth_app/pages/product/simple_input_number_field.dart:37:22)
#2      _EditNewPackagingsState.initState (package:smooth_app/pages/product/edit_new_packagings.dart:70:51)
#3      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5219:55)
#4      ComponentElement.mount (package:flutter/src/widgets/framework.dart:5062:5)
...     Normal element mounting (220 frames)
#224    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3971:16)
#225    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6570:36)
#226    Element.updateChild (package:flutter/src/widgets/framework.dart:3708:18)
#227    RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:6153:32)
#228    MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6595:17)
#229    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#230    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#231    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5251:11)
#232    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#233    StatefulElement.update (package:flutter/src/widgets/framework.dart:5274:5)
#234    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#235    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#236    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#237    ProxyElement.update (package:flutter/src/widgets/framework.dart:5417:5)
#238    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#239    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#240    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#241    ProxyElement.update (package:flutter/src/widgets/framework.dart:5417:5)
#242    _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:107:11)
#243    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#244    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#245    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5251:11)
#246    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#247    StatefulElement.update (package:flutter/src/widgets/framework.dart:5274:5)
#248    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#249    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#250    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#251    ProxyElement.update (package:flutter/src/widgets/framework.dart:5417:5)
#252    _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:107:11)
#253    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#254    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#255    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5251:11)
#256    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#257    StatefulElement.update (package:flutter/src/widgets/framework.dart:5274:5)
#258    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#259    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#260    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5251:11)
#261    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#262    StatefulElement.update (package:flutter/src/widgets/framework.dart:5274:5)
#263    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#264    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6442:14)
#265    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#266    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6442:14)
#267    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#268    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#269    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#270    ProxyElement.update (package:flutter/src/widgets/framework.dart:5417:5)
#271    Element.updateChild (package:flutter/src/widgets/framework.dart:3686:15)
#272    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5111:16)
#273    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5251:11)
#274    Element.rebuild (package:flutter/src/widgets/framework.dart:4805:7)
#275    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2780:19)
#276    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:903:21)
#277    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:358:5)
#278    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1284:15)
#279    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1214:9)
#280    SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1072:5)
#281    _invoke (dart:ui/hooks.dart:142:13)
#282    PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:359:5)
#283    _drawFrame (dart:ui/hooks.dart:112:31)
════════════════════════════════════════════════════════════════════════════════════════════════════

I'm trying to reproduce them, but I'm out of luck at the moment.

@g123k g123k added the 🐛 bug Something isn't working label Aug 21, 2023
@monsieurtanuki
Copy link
Contributor

Both issues are because the country is not populated: how is it possible?

@g123k
Copy link
Collaborator Author

g123k commented Aug 23, 2023

@saiprasad-patil: You said me your app was set to Andorra. Was-it your choice in the onboarding?

@saiprasad-patil
Copy link
Contributor

No I remember choosing India, but have no idea how it was set to Andora. There's a chance it might have set when I reinstalled the app and might have changed it accidentally.

@monsieurtanuki
Copy link
Contributor

There may be cases when the country is set to null, when for some reason the country iso code is not recognized.
The setCountry method is used at app init time, and when the user changes the country.

There are several solution options:

  • use a default value for getCountry, that would return for instance FRANCE instead of null
  • be more aggressive when we try to set the country to null
    • if it's when the user changes the country, display a "sorry couldn't change the country" message and send a sentry message.
    • if it's at app init time, use a default value

@saiprasad-patil Are you able to reproduce the issue, like if you install/reinstall the app?

// (from ProductQuery)
  static Future<void> setCountry(
    final UserPreferences userPreferences, {
    String? isoCode,
  }) async {
    isoCode ??= userPreferences.userCountryCode ??
        PlatformDispatcher.instance.locale.countryCode?.toLowerCase();
    _country = CountryHelper.fromJson(isoCode);
    // we need this to run "world" queries
    OpenFoodAPIConfiguration.globalCountry = null;

    isoCode = _country?.offTag;
    if (isoCode != null && isoCode != userPreferences.userCountryCode) {
      await userPreferences.setUserCountryCode(isoCode);
    }
  }

@saiprasad-patil
Copy link
Contributor

saiprasad-patil commented Aug 23, 2023

Try these steps:

  • Install app from play store
  • Let the country be set to default(Andorra)
  • Search for a product
  • Open the product's "edit product" screen
  • Click on "nutrition facts" or "packaging components"

(Also while uninstalling make sure to clear data so you have to sign in again, I created a new account to test this)

@monsieurtanuki
Copy link
Contributor

Let the country be set to default(Andorra)

@saiprasad-patil I think I found part of the problem: you're not supposed to start with Andorra. You're supposed to start with your device's country, so it looks like it wasn't detected (unless you're from Andorra).
As you have not explicitly changed the country (you just clicked on "next"), your country is probably still null.

That means that we're not 100% good with detecting device countries
=> and we should probably set an explicit default value. Let it be France.

In addition to that we should be more aggressive with "wrong countries" (could not understand the country code for some reason).

Additional thought: needs to be tested with uk and gb that is a special case.

(Also while uninstalling make sure to clear data so you have to sign in again, I created a new account to test this)

The data is cleared automatically. If it's not the case please create an issue.

@monsieurtanuki monsieurtanuki self-assigned this Aug 23, 2023
@saiprasad-patil
Copy link
Contributor

saiprasad-patil commented Aug 23, 2023

The data is cleared automatically. If it's not the case please create an issue

No it was with regards to the option some phones give to keep app data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants