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

Tooltip could crash during runtime because of preconditionFailure() #611

Open
2 tasks done
imWildCat opened this issue Jun 20, 2021 · 2 comments
Open
2 tasks done

Comments

@imWildCat
Copy link

imWildCat commented Jun 20, 2021

Environment Information

  • Platform:
    • iOS: any
    • macOS: any
  • Package version(s): (fill this out, include which package manager you're using): latest
  • Xcode and OS versions: (fill this out if relevant): any version supported

Please provide a reproduction of the bug:

The anchorView's window can be nil when it got removed from the view hierarchy.
In this situation, preconditionFailure() will lead to runtime crash.

Since Tooltip isn't a critical UI for most business logic, should we crash the app when this exception happens?

I searched for preconditionFailure() in this repo (https://github.com/microsoft/fluentui-apple/search?p=1&q=preconditionFailure) and found that most of its use is for unimplemented initializers.

Actual behavior:

Tooltip could crash the app.

Expected behavior:

This UI component shouldn't crash app. Or at least, we can have an alternative to crash (runtime error log?)

Priorities and help requested:

Are you willing to submit a PR to fix? No. Or yes if we have a clear path to fix it.

Requested priority: Normal

@imWildCat imWildCat changed the title Tooltip could crash during runtime because of Tooltip could crash during runtime because of preconditionFailure() Jun 20, 2021
@harrieshin
Copy link
Contributor

Thanks for the feedback. runtime error log is bit messy to do as a shared UI library because each client team might have different way of error logging and most of the time developers tend to ignore logs on the console. I think author's thoughts were to make sure clients understand the tooltip is actually showing on a valid anchor view and crashing might be the best way to debug user scenarios if things are not shown in intended way.

@imWildCat
Copy link
Author

Thanks @harrieshin!

Yeah, I agree the anchorView should be in the view hierarchy (and the window of it shouldn't be nil) while showing Tooltip.
This should be a precondition.

Could we consider other alternative approach? Like returning a Result<Void, Error> enum to make it more flexible?

In large apps, the view hierarchy could be complex. As a result, when Tooltip.show() is executed by the runloop, the anchorView.window might be nil even if the developer is very careful about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants