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

[Bug]: iOS object variable not set as soon it hits OneSignal when using Hot Restart #67

Open
1 task done
gabsamples6 opened this issue Sep 26, 2023 · 24 comments
Open
1 task done

Comments

@gabsamples6
Copy link

gabsamples6 commented Sep 26, 2023

What happened?

  1. Launch the app
  2. when OneSignal.Debug.LogLevel = LogLevel.VERBOSE; is hit
  3. Get System.NullReferenceException: Object reference not set to an instance of an object.
    at OneSignalSDK.DotNet.iOS.iOSDebugManager.set_LogLevel(LogLevel value)

on any OneSignal call I get the above

Steps to reproduce?

1. Launch the app 
2. when     OneSignal.Debug.LogLevel = LogLevel.VERBOSE; is hit
3. Get  System.NullReferenceException: Object reference not set to an instance of an object.
   at OneSignalSDK.DotNet.iOS.iOSDebugManager.set_LogLevel(LogLevel value)

on any OneSignal call I get the above

What did you expect to happen?

Run the app so that I can initialize onesignal and send notification

Any suggestions

Relevant log output

System.NullReferenceException: Object reference not set to an instance of an object.
   at OneSignalSDK.DotNet.iOS.iOSDebugManager.set_LogLevel(LogLevel value)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@shepherd-l
Copy link
Contributor

What .Net version are you using and what version is your Visual Studio?

@gabsamples6
Copy link
Author

@shepherd-l using

  • visual studio 2022 17.7.4
  • <PackageReference Include="OneSignalSDK.DotNet" Version="5.0.0" />
  • .net 7
    and also happens with Version Visual Studion 17.8.0 Preview 2.0 .net 8 (which we will be moving as its now got a live licence)

@shepherd-l
Copy link
Contributor

Could you share a sample project with us that reproduces the issue?

@gabsamples6
Copy link
Author

@shepherd-l see attached project

See simple attached example - the main point of this sample is that it crashes in iOS when hitting the first line of code where Onesignal is used.

  1. Launch app in android

  2. Breakpoint on SharedPush.Initialize

  3. OneSignal.Debug all good

  4. Launch app in iOS

  5. Breakpoint on SharedPush.Initialize - OneSignal.Debug

  6. Crash -Object variable not set when breakpoint hit

Google-services json and entitlement.plist are empty as not important to demonstrate this bug

Attachment here
OneSignalPoC.zip

thanks again for looking into this.

@gabsamples6
Copy link
Author

Any news? have you been able to replicate it?

@Zack-G-I-T
Copy link

@shepherd-l we have the same problem. Works fine on Android MAUI, but on ios we cant do anything with onesignal. We tried copying the sample app but cannot get it working. Is there some missing setup or something?

@shepherd-l
Copy link
Contributor

I was unable to reproduce the error with the 5.0.2 release

Could you try upgrading to 5.0.2 and let us know if you are still seeing the issue?

@Zack-G-I-T could you also try upgrading to 5.0.2 as well?

@gabsamples6
Copy link
Author

@shepherd-l hi there thanks for the update but we are still having the same problem in iOS using 5.0.2 .. Can you tell me or share a project that worked for you?

@shepherd-l
Copy link
Contributor

Let us know if this project works for you: https://drive.google.com/file/d/1OpZjo1G0BZBmeBOp1g_GeyxKfoNAYcIO/view?usp=share_link

I’m using

  • Visual Studio 17.6.5
  • .Net 8

@gabsamples6
Copy link
Author

@shepherd-l hi thanks for the link but still not working for me -

  1. Launch the dotnet8 app in Visual studio 17.8.0 Preview 3.0 .net 8 (same with .net 7) or any version of visual studio
  2. Local iOS device
  3. As soon as it hits Onesignal.Debug you get
    image

@emawby
Copy link
Contributor

emawby commented Oct 23, 2023

@gabsamples6 Something about your dev environment must be different and is causing the issue so we should try to track it down. Is this working on Android for you? If you remove that debug line does it run for you?

@gabsamples6
Copy link
Author

gabsamples6 commented Oct 24, 2023

@emawby hi -

  • Works in android
  • Any OneSignal line that it hits it will crash in iOS.-
  • Using Windows 10/11 with an iPhone attached (hot restart) and issue occurs in both .net 7 and net 8 latest RC

Are you using a Mac? - we dont use mac for development as visual studio for mac is too buggy

@gabsamples6
Copy link
Author

Any news? did you manage to replicate the issue?

@gabsamples6
Copy link
Author

@shepherd-l @emawby hi there , is there any news on this one , have you been able to replicate the issue ?

many thanks

@emawby
Copy link
Contributor

emawby commented Oct 31, 2023

Hello we have not been able to replicate the issue yet. I imagine that this is because you are using Windows and we are using Mac. Are you using a physical device or a simulator? Do you know which build tools your visual studio uses for iOS builds?

@gabsamples6
Copy link
Author

Hi I am using a physical device as described in the instructions using windows pc and latest visual studio .i tried against 3 iPhone and same issue

@emawby
Copy link
Contributor

emawby commented Oct 31, 2023

@gabsamples6 Do you have a mac build host for your iOS builds? If so what xcode version/xcode build tools are you using on the host?

@gabsamples6
Copy link
Author

We build the app using azure devops pipelines using Microsoft hosted agents . Are u familiar with hot restart? That allows us to debug the app using a physical device without the usage of a Mac. Visual studio for Mac has been made obsolete and we had problem building our app that has more than 100 pages .so we use a pc . I do thing you should have a pc has this is an extremely common scenario

@jkasten2 jkasten2 changed the title [Bug]: iOS object variable not set as soon it hits OneSignal [Bug]: iOS object variable not set as soon it hits OneSignal when using Hot Restart Nov 2, 2023
@shepherd-l
Copy link
Contributor

We were able to reproduce your issue. Development builds with hot restart don’t seem to work with our SDK.

Production builds work for us when we connect the iOS device to the Mac directly instead of the Windows machine.

We recommend doing production builds with the device connected to the Mac as a workaround for now.

@shepherd-l shepherd-l added Bug Something isn't working Reproducible labels Nov 3, 2023
@shepherd-l shepherd-l added iOS and removed Bug Something isn't working labels Nov 3, 2023
@gabsamples6
Copy link
Author

Hi
We debugging we use a windows pc and connect an iPhone to it , bcse vs for mac has so many issues..

When we deploy we use Azure pipeline. that being said - are you in a position to tell us when the issue will be fixed?

many thanks

@emawby
Copy link
Contributor

emawby commented Nov 16, 2023

We are working on bumping our minimum version to .net7 which may help with this issue, but we have not been able to identify a fix yet for windows builds where the device is connected to the windows machine. We are still investigating.

@gabsamples6
Copy link
Author

@emawby anynews? many thanks

@emawby
Copy link
Contributor

emawby commented Jan 17, 2024

@gabsamples6 The update to .net7 will be available in the next release of this SDK. Thank you for your patience this has been a tricky one to resolve.

@gabsamples6
Copy link
Author

@emawby wonder why you are sticking to .net 7 when in no longer supported and not move to .net 8 , so are you saying that this also solves the issue of the object variable not set in debug time using a windows pc connected to a physical ios device?

And when is next release scheduled for?

A prompt reply would be very very welcome.

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

No branches or pull requests

7 participants