Schlaubischlump / LocationSimulator

MacOS application to spoof / fake / mock your iOS / iPadOS or iPhoneSimulator device location. WatchOS and TvOS are partially supported.
https://schlaubischlump.github.io/LocationSimulator/
GNU General Public License v3.0
2.39k stars 184 forks source link

[BUG] location not updating if app is in background #96

Open mattiamalonni opened 2 years ago

mattiamalonni commented 2 years ago

Describe the bug Location not updating if app is in background mode

To Reproduce Steps to reproduce the behavior:

  1. Open the app
  2. Use it normally
  3. Open another app and keep it on focus
  4. After a while, location will not update

Expected behavior Location will still update, even if is in background

Desktop (please complete the following information):

Smartphone (please complete the following information):

Schlaubischlump commented 2 years ago

I already noticed this as well. This has to do with the BackgroundQueue I use in the LocationSpoofer class. I already read the docs, but I have no idea how to accomplish this...

Schlaubischlump commented 2 years ago

I tried to reproduce this behaviour on mac OS 12, and for some reason the error does not occur. Can somebody else verify that the behaviour did indeed change ?

Schlaubischlump commented 2 years ago

Should be fixed in v0.1.9. I removed the usage of NSTimer / Timer and use a DispatchQueue instead. This should work even if the app is in the background.

Entrepren commented 2 years ago

Sorry, but the bug is persistent in version 0.1.9.1. The active window must be the location simulator app. Otherwise there‘s the message „Error changing location“ (https://github.com/Schlaubischlump/LocationSimulator/issues/117#issue-1190897471).

And so you can’t use location simulator with two instances of the app, because only one window can be in foreground.

iOS 15.4.1 and macOS 12.3.1

Schlaubischlump commented 2 years ago

First thing first: Running two instances at the same time is not a scenario I actively test or support. That being said:

I can not reproduce this behaviour. I started two instances of LocationSimulator via terminal and started spoofing on both instances. Then I put a different app in the foreground. Everything is working. Can you write down step by step instructions of how to produce the error? The error message indicates, that there is a problem setting the location. The error described in this issue addresses the problem, that the interface is not updating since the queue is not sending any more updates. This here is a different error, since the update is send, but it fails. This is therefore a different (new ?) bug.

I assume you did not try to spoof the location of the same device with both instances of LocationSimulator, because this will obviously not work.

Can you send me your LocationSimulator log. Click on Help -> Log... and Export. This generates a log file which you can upload here (Note: It might contain your device ids and names).

Schlaubischlump commented 2 years ago

I took a look at the logs. The error occurs somewhere deep down in libimobiledevice. When trying to connect to the device lockdown returns error code -5, which means LOCKDOWN_E_SSL_ERROR. I'm not sure why this error occurs. It could be some coding error on my end or some error inside libimobiledevice. In every case it seems strange, that it only occurs when interacting with the mac. I try to investigate I little more and see if I find something out. It could very well be, that this error is out of my control and even out of control of libimobiledevice.

Schlaubischlump commented 2 years ago

Okay seems like the navigation is still paused when the app is in the background for too long... That means the original error does still exist. The location is updated just not as often as it should be. This seems like a system optimization to save computing power. Don't know if I can do anything about this.

Nevertheless I'm unable to reproduce the newly reported error. In every case I keep this issue open for now.

Entrepren commented 2 years ago

The iPhone is connected via original lightning to usb-a cable and usb-c to usb-a adapter (both from Apple Store). I will try a usb-c to lightning cable later to exclude adapter related problems and report if this changes anything. Maybe iPhone 6s is short on RAM? Will try iPad instead.

Schlaubischlump commented 2 years ago

Both good ideas. I debugged using the Wi-Fi connection. I'll try again via a USB connection. The USB connection is faster, maybe this contributes to the error.

Entrepren commented 2 years ago

Connection and cable checks revealed no further information. iPad same situation. But I found out that running a specific tracking app (https://apps.apple.com/us/app/racemap/id640797527) on the iDevice AND leaving location simulator in background causes the error message. So I assume the problem is on the device/app side. Will send new log file