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

Freezing on macOS Monterey #18

Closed
chriswmartin opened this issue Jun 29, 2021 · 11 comments
Closed

Freezing on macOS Monterey #18

chriswmartin opened this issue Jun 29, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@chriswmartin
Copy link

After clicking the menu bar icon the application freezes and must be force quit.

Looking in Xcode 13 this line is flagged with the error:

Fatal error: No ObservableObject of type RemindersData found. A View.environmentObject(_:) for RemindersData may be missing as an ancestor of this view.

Let me know if there is any other information I can provide that would be helpful.

@DamascenoRafael DamascenoRafael added the bug Something isn't working label Jul 11, 2021
@alicerunsonfedora
Copy link

I am unsure if there's been an update to address this, but I can confirm that this is still an issue with the latest Monterey dev beta (21A5294g).

@DamascenoRafael
Copy link
Owner

I still can't figure out what causes this error.
In Big Sur, even in Xcode 13 beta there is no problem.
The error would be as if ".environmentObject(remindersData)" was not present.
Maybe creating a SceneDelegate can help, but it still feels weird.

@alicerunsonfedora
Copy link

The error would be as if ".environmentObject(remindersData)" was not present.

Is it possible that this method is deprecated in favor of something else? I've never seen this before with SwiftUI.

@twenrut
Copy link

twenrut commented Aug 27, 2021

still persists

@alicerunsonfedora
Copy link

still persists

I don't believe the issue has been resolved as of yet. I haven't seen a release update to fix this yet.

@DamascenoRafael
Copy link
Owner

Hey, @chriswmartin , @alicerunsonfedora, @twenrut.
Since I'm not using macOS Monterey yet, could one of you run some tests?

  1. In AppDelegate.swift remove the @NSApplicationMain annotation and add @main instead.

  2. If it doesn't work and the error continues: remove the @main annotation from the AppDelegate class and above that declaration add the code below:

    @main
    struct RemindersMenuBar: App {
        @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
        
        var body: some Scene {
            Settings {
                EmptyView()
            }
        }
    }

    In the AppDelegate class make the following changes:

      let popover = NSPopover()
    - let statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
    + var statusBarItem: NSStatusItem!
      private func configureMenuBarButton() {
    +     statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
          statusBarItem.button?.image = NSImage(systemSymbolName: "list.bullet", accessibilityDescription: nil)
          statusBarItem.button?.imagePosition = .imageLeading
          statusBarItem.button?.action = #selector(togglePopover)
      }

Please let me know if 1 or 2 fixed the problem or changed the initial error.

@pie6k
Copy link

pie6k commented Sep 20, 2021

I am not able to test the code you provided, but it indeed freezes for me as well.

When I open the app - it shows up in menu bar with count number of reminders, but as soon as I click it - it freezes, shows spinner mouse cursor and CPU is at 100%

@pie6k
Copy link

pie6k commented Sep 20, 2021

Ok, I tried your code changes.

I did build it natively (M1 mac) and it did not run (with error 'could not attach to process PID: ').

Then I tried Rosetta build and it worked and built, but then crashed:

extension NSTextField {
    open override var focusRingType: NSFocusRingType {
        get { .none }
        set { self.focusRingType = newValue } // <—- error here `Thread 1: EXC_BAD_ACCESS (code=2, address=0x304989ff8)`
    }
}

CleanShot 2021-09-20 at 17 02 22@2x

[update]

After also commenting out this extension - it started to work (in Rosetta build, no native M1 build)

@DamascenoRafael
Copy link
Owner

Thanks for the help @pie6k.
I just updated to macOS Monterey Beta and I'm verifying it.
This extension has no effect in Monterey but is important in Big Sur.
Removing the set from this property seems to solve the problem.

@DamascenoRafael
Copy link
Owner

@pie6k, @chriswmartin , @alicerunsonfedora, @twenrut
New release v1.6.0 should resolve this issue. Sorry for taking so long.
Please let me know if something doesn't work as expected.

@DamascenoRafael
Copy link
Owner

Closing this issue since everything seems to be ok :)
New version 1.6.1 fixes another bug on macOS Monterey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants