Skip to content

Null check operator used on a null value #67

@d9media

Description

@d9media

Hi guys,

I recently investigated an issue where our app would get stuck at splashscreen for some users. I'm now convinced I can reproduce the issue.

When you enable "use network-provided time zone" in Android (settings > system > date&time) , initialization of TimeMachine fails with the following stacktrace:

I/flutter (26553): ----------------FIREBASE CRASHLYTICS----------------
I/flutter (26553): Null check operator used on a null value
I/flutter (26553):
I/flutter (26553): #0      TimeMachine.initialize
package:time_machine/…/platforms/vm.dart:95
I/flutter (26553): <asynchronous suspension>
I/flutter (26553): #1      main.<anonymous closure>
package:***/main.dart:115
I/flutter (26553): <asynchronous suspension>
I/flutter (26553): #2      main
package:***/main.dart:110
I/flutter (26553): <asynchronous suspension>

pointing to vm.dart:93 ff.:

   var local = timeZoneOverride != null ? await tzdb.getZoneOrNull(timeZoneOverride) : await _figureOutTimeZone(tzdb);
    // todo: cache local more directly? (this is indirect caching)
    TzdbIndex.localId = local!.id;   // <-- baaang

When you set a location instead, everything works. I can't say whether this is an issue for iOS too but we did have user reports with a similar crash pattern.

It looks local can be null when network-provided time fails or timezone is set to GMT. In that case, we can't use null operator.

I don't really know TimeMachine well enough yet to suggest a solution but I still wanted to bring this your attention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions