Wordpress-android: SiteCreationService already registered to event class org.wordpress.android.fluxc.store.SiteStore$OnNewSiteCreated

Created on 19 Dec 2018  ·  7Comments  ·  Source: wordpress-mobile/WordPress-Android

This issue appears to be caused by not checking whether the service is already registered before performing registration.

Stack Trace:

Non-fatal Exception: org.greenrobot.eventbus.EventBusException: Subscriber class org.wordpress.android.ui.accounts.signup.SiteCreationService already registered to event class org.wordpress.android.fluxc.store.SiteStore$OnNewSiteCreated
       at org.greenrobot.eventbus.EventBus.subscribe(EventBus.java:154)
       at org.greenrobot.eventbus.EventBus.register(EventBus.java:139)
       at org.wordpress.android.fluxc.Dispatcher.register(Dispatcher.java:24)
       at org.wordpress.android.ui.accounts.signup.SiteCreationService.onProgressStart(SiteCreationService.java:206)
       at org.wordpress.android.util.AutoForeground.setState(AutoForeground.java:165)
       at org.wordpress.android.ui.accounts.signup.SiteCreationService.setState(SiteCreationService.java:256)
       at org.wordpress.android.ui.accounts.signup.SiteCreationService.onStartCommand(SiteCreationService.java:309)
       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3085)
       at android.app.ActivityThread.access$2300(ActivityThread.java:164)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1560)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:160)
       at android.app.ActivityThread.main(ActivityThread.java:5541)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

reference: 5aa6d8f98cb3c2fa63e548ff-fabric
impact: unknown – I'm not able to determine the impact of failing to register the service with the dispatcher.

Site Creation [Type] Bug

Most helpful comment

I've added this issue to our project so we can close it once everything is merged to develop.

All 7 comments

Suggestion for a partial solution – EventBus contains a method called isRegistered.

Could that be used in the FluxC Dispatcher, such that instead of the try/catch pair, we could just check if the service is already registered?

Context:

https://github.com/wordpress-mobile/WordPress-Android/blob/3806d6f7cefc067b4c12f20a5f602556c87255f3/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SiteCreationService.java#L201-L211

Paging @oguzkocer / @hypest for your thoughts :)

@jkmassel I would leave this one for now unless there is some urgency because this class is somewhat re-written in the new site creation flow in #8795. It's not yet merged to develop, but we are getting close to it.

@malinajirka Is this something we need to worry about in the new service?

I'm happy to leave this until the new site creation flow ships, for sure!

If we're reworking it anyway, it's great that we can do so while being aware of this :)

As you already mentioned it's related to 7353. As far as we know it shouldn't affect the users.

https://github.com/wordpress-mobile/WordPress-Android/blob/99aa8ba2cb6674e1d25e63afe3a9d5dc6b80e7f2/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SiteCreationService.java#L207

@malinajirka Is this something we need to worry about in the new service?

I hope not. I've moved the registration/unregistration to onCreate and onDestroy, so unless the OS actually creates two instances of the service (which is highly improbable) we should be safe. However, I've removed the try/catch block so if it keeps happening it'll start crashing the app -> so we should keep an eye on it.

I've added this issue to our project so we can close it once everything is merged to develop.

As discussed before, this issue should be fixed in feature/master-site-creation branch which should be merged before 11.6 release. I am closing this issue a little early so we can focus on what's left on the project board.

P.S: I keep checking this issue even though I know we'll just close it soon, that's why I am actually closing it 🤦‍♂️

Was this page helpful?
0 / 5 - 0 ratings