Skip to content

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Oct 11, 2025

Should fix #15771

Despite appearances, basically a one like change. The rest is just indentation change because the early return eliminates the need to have the rest inside the replaced conditional.

  • Tests written, or not not needed


val user = optionalUser.get()
setupDrawer()
if (!optionalUser.isPresent || storageManager == null) return
Copy link
Collaborator

@alperozturk96 alperozturk96 Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey. Thank you for the PR.

if (optionalUser.isPresent && storageManager != null) {
if (!optionalUser.isPresent || storageManager == null) return

These two conditions are logically equivalent — they express the same control flow in opposite forms. Therefore, changing one to the other wouldn’t actually resolve the issue.

The real problem likely occurs when the app is suspended and then resumed, during which the state (such as optionalUser or storageManager) is lost or not properly restored.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two conditions are logically equivalent — they express the same control flow in opposite forms. Therefore, changing one to the other wouldn’t actually resolve the issue.

Switching the conditions permits the early return, which avoids running the later NPE code path though, right? (which in the existing code happens outside the conditional)

The real problem likely occurs when the app is suspended and then resumed, during which the state (such as optionalUser or storageManager) is lost or not properly restored.

I can't argue there. Admittedly did not go down that rabbit hole.

I guess the path forward comes down to two questions:

  • Is the true underlying problem (suspend/resume state) readily fixable in the near future?
  • What's the impact (cons specifically) of returning w/o at least crashing (as proposed in this PR)? I.e., Are we likely introducing new problems or just working around one until we can identify and fix the state matter?

I don't have the answers. Just posing to think about these a bit myself. :) To answer I'd have to take a deeper dive, which admittedly I haven't on this matter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn’t seem likely to introduce any new issues, so we can go ahead and merge it. It might even help by returning early instead of failing within the condition.

As for the actual fix, it’s not an easy issue to reproduce or verify because of the tightly coupled, nested fragment hierarchy and the complexity of tracking their lifecycles. The NPE seems related to a specific execution flow — in theory, if the optional user is present, the user object should be accessible, but it appears there’s a lifecycle-related issue causing the null reference.

I’ll investigate this further, but thank you for the PR 🙏

@github-actions
Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/15775.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crash on Account login

2 participants