tattwei46 / flutter_login_demo

A demo login app with Flutter and Firebae
369 stars 215 forks source link

Stuck On Loading Animation After Login #3

Closed komputerboy closed 5 years ago

komputerboy commented 5 years ago

Hi,

Now i push another issue. I stuck in loading animation after login. But when i close it, then open it again, this app is getting to home page(login succes). This is what i got:

Built build\app\outputs\apk\debug\app-debug.apk. Installing build\app\outputs\apk\app.apk... E/FirebaseInstanceId(24845): Failed to resolve target intent service, skipping classname enforcement E/FirebaseInstanceId(24845): Error while delivering the message: ServiceIntent not found. Syncing files to device SM J111F... I/Timeline(24845): Timeline: Activity_idle id: android.os.BinderProxy@34f8d794 time:7280156 V/ActivityThread(24845): updateVisibility : ActivityRecord{13438a32 token=android.os.BinderProxy@34f8d794 {com.example.flutterlogindemo/com.example.flutterlogindemo.MainActivity}} show : true I/Timeline(24845): Timeline: Activity_idle id: android.os.BinderProxy@34f8d794 time:7297582 D/ViewRootImpl(24845): ViewPostImeInputStage ACTION_DOWN D/ViewRootImpl(24845): ViewPostImeInputStage ACTION_DOWN D/ViewRootImpl(24845): ViewPostImeInputStage ACTION_DOWN D/ViewRootImpl(24845): ViewPostImeInputStage ACTION_DOWN D/ViewRootImpl(24845): ViewPostImeInputStage ACTION_DOWN D/ViewRootImpl(24845): ViewPostImeInputStage ACTION_DOWN W/BiChannelGoogleApi(24845): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@1effaff4 D/FirebaseAuth(24845): Notifying id token listeners about user ( ml3Xd8iKW0eUmlhz5g6RXw5OS902 ). D/FirebaseAuth(24845): Notifying auth state listeners about user ( ml3Xd8iKW0eUmlhz5g6RXw5OS902 ). D/FirebaseApp(24845): Notifying auth state listeners. D/FirebaseApp(24845): Notified 0 auth state listeners. W/System.err(24845): remove failed: ENOENT (No such file or directory) : /data/data/com.example.flutterlogindemo/shared_prefs/com.google.firebase.auth.api.Store.W0RFRkFVTFRd+MTo1MDMzNzAyMzU4NTc6YW5kcm9pZDoyNTNlMWRhOTgwZDQwYmU0.xml.bak I/flutter (24845): Signed in: ml3Xd8iKW0eUmlhz5g6RXw5OS902 V/ActivityThread(24845): updateVisibility : ActivityRecord{13438a32 token=android.os.BinderProxy@34f8d794 {com.example.flutterlogindemo/com.example.flutterlogindemo.MainActivity}} show : true I/Timeline(24845): Timeline: Activity_idle id: android.os.BinderProxy@34f8d794 time:7338300 D/ViewRootImpl(24845): ViewPostImeInputStage ACTION_DOWN

My Environment is:

Flutter1.0.0 • channel beta • https://github.com/flutter/flutter.git Framework • revision 5391447fae (4 weeks ago) • 2018-11-29 19:41:26 -0800 Engine • revision 7375a0f414 Tools • Dart 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

Try to build it with: Android Studio 3.1.3

I have tried it in three phone, but still get same issue.

Thanks

tattwei46 commented 5 years ago

Hi @komputerboy,

I tried on both ios simulator and android emulator but unable to reproduce the issue.

Is this happens for every signups?

Thanks, David

tattwei46 commented 5 years ago

Hello @komputerboy ,

This is my log. Seems there is no auth state listeners in your failed case.

D/FirebaseAuth(15911): Notifying id token listeners about a sign-out event. D/FirebaseAuth(15911): Notifying auth state listeners about a sign-out event. D/FirebaseApp(15911): Notifying auth state listeners. D/FirebaseApp(15911): Notified 1 auth state listeners. I/zygote (15911): Do full code cache collection, code=122KB, data=92KB I/zygote (15911): After code cache collection, code=107KB, data=63KB W/BiChannelGoogleApi(15911): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@2b6a891 D/FirebaseAuth(15911): Notifying id token listeners about user ( 2JLdqctPKAd3em0Ksy7xKVj5nxr2 ). D/FirebaseApp(15911): Notifying auth state listeners. D/FirebaseApp(15911): Notified 1 auth state listeners. D/FirebaseAuth(15911): Notifying auth state listeners about user ( 2JLdqctPKAd3em0Ksy7xKVj5nxr2 ). I/flutter (15911): Signed in: 2JLdqctPKAd3em0Ksy7xKVj5nxr2

tattwei46 commented 5 years ago

Hello @komputerboy ,

Finally I am able to reproduce the issue. Criteria is i have to uninstall the app first.

So this is due to the asynchronous event of the following:

void _onLoggedIn() { widget.auth.getCurrentUser().then((user){ _userId = user.uid.toString(); }); setState(() { authStatus = AuthStatus.LOGGED_IN; }); }

The event will not wait to retrieving uid to be completed, hence the uid is null. And in the build method, when AuthStatus.IS_LOGGED_IN, there is a check whether the uid is empty or not. Hence returning loading screen. When the async event is completed, and the valid uid is retrieve, there is no way the program knows the updated uid as there is not set state. To fix this, we simply wrap it with a setstate.

I have pushed the fix 8ee46f23cbce2f5179fc035af2f32ebf6d6a5883, kindly resync and validate. Thanks for reporting issue.

Regards, David

komputerboy commented 5 years ago

thanks, i will try it..

komputerboy commented 5 years ago

okay, now it fixed. I will close it