You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/10/15 21:20:43 UTC

[GitHub] [cordova-plugin-device] SailingSteve opened a new pull request #133: (iOS)(Apple Silicon Processor) Add ability to detect Cordova running on desktop with Apple Silicon

SailingSteve opened a new pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133


   # Platforms affected
   iOS 14 and up
   
   
   
   ### Motivation and Context
   When running on iOS14, on a Mac that has an Apple Silicon processor (ARM64 instead of Intel), this change exposes the iOS variable `isiOSAppOnMac`.
   
   This minor change exposes the iOS `isiOSAppOnMac` variablw, which is the definitive way to detect that the Cordova iOS app is running on the Mac desktop on a non-Intel processor.
   
   On Apple Silicon the hardware menu (wifi, clock, cell strength, battery) goes away, and other container changes need to be compensated for, so access to this variable is essential.  This plugin seems like the best place to expose this variable.
   
   ### Description
   in the iOS NSProcessInfo under iOS 14+, a new system variable has been defined, this change exposes that variable.
   
       [NSProcessInfo processInfo].isiOSAppOnMac
   
   
   
   ### Testing
   This change works on iOS 14 on macOS Big Sur Version 11.0 Beta 8 (20A5374i) running on an Apple A12Z processor.
   The change causes no problem (returns false) on macOS Catalina Version 10.15.6 running on an Intel processor inside an iOS simulator (SE 2nd Gen, 8 Plus 13.3, 11 Pro 14.0, 11 13.3, iPadPro 9.7" 14.0, iPadPro 12" 4th gen 14.0), and on a physical 
   iPhone Xs Max running iOS 13.7.
   Also no problem on an Android simulator for a Galaxy Tab S5e, and a Galaxy S9+ at API 30, and a Moto G5 plus (Android 8.1.10) physical phone.
   
   
   
   ### Checklist
   
   - [ ] I've run the tests to see all new and existing tests pass
   - [ ] I added automated test coverage as appropriate for this change
   - [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
   - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
   - [ ] I've updated the documentation if necessary
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] SailingSteve commented on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
SailingSteve commented on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-712406166


   @erisu I initially used cordova-plugins-diagnostic to find out that the architecture is ARM64.  Then I realized that both the phones and the Mac will be using ARM64 at some point, so the architecture can't be used to determine the equivalent of `isiOSAppOnMac`.
   
   By the way, I have no attachment to the variable name `isiOSAppOnMac`, we can name it whatever we want, but I just defaulted to the name Apple chose.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] erisu edited a comment on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
erisu edited a comment on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-711471219


   IMO, I don't see a need for a new property.
   
   I feel that using both the `device.model` and `device.platform` together should be enough to identify if the iOS app is running on a macOS and on which architecture.
   
   To recap from what I am reading and understanding from the documentation written in the repo's README,
   
   Focusing on the case of building an iOS app and running on a macOS, I expect:
   
   * The `device.platform` to return `iOS`. This value is hardcoded [here](https://github.com/apache/cordova-plugin-device/blob/master/src/ios/CDVDevice.m#L91) for the Cordova iOS platform.
   * The `device.model` should return the device's architecture. `x86_64` or `ARM64`
   
   The information in the README says iOS will return the device model (e.g. `iPhone 5,1`), but when running on a macOS, the device model is the hardware's architecture.
   
   I confirmed this when running a quick playground test on a macOS, using the same code from [here](https://github.com/apache/cordova-plugin-device/blob/master/src/ios/CDVDevice.m#L29-L43).
   
   So to recap, running an iOS app on a macOS, I am expecting:
   * `device.platform` to equal `iOS`
   * `device.model` to equal either `x86_64` or `ARM64`
   
   I think these two properties combined is enough to know where the iOS app is running and also provides on which architecture when on a macOS.
   
   Since we have two existing properties that can be used to create the boolean check and is something that is usable by multiple platforms, can you explain if there are any other reasons why a new property that is only iOS specific is needed?
   
   Example Boolean Check:
   
   ```
   if (
     device.platform === 'iOS' 
     && (
       device.model  === 'x86_64'
       || device.model  === 'ARM64'
     )
   ) {
     // code here
   }
   ```
   
   NOTE: I have not confirmed if `device.model` returns `ARM64` as I do not own an Apple Silicon. The printout might be formatted differently. For example all lowercase, or with spaces, etc. The information is based on expectation from how it works today and what I have tested on my macOS.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] erisu commented on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
erisu commented on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-711471219


   I personally don't see what is the need of this new property. I feel that using both the `device.model` and `device.platform` should be enough to identify what is running on what device. 
   
   To recap from the documents printed in the README of this repo,
   
   `device.platform` should return either `iOS` or `Mac OS X`. But since we are talking about building an iOS app with the Cordova iOS platform, `iOS` will always be returned. This value is hardcoded.
   
   `device.model` should return one of the following two cases:
   
   ```
   // iOS:     for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
   // OSX:                        returns "x86_64"
   ```
   
   From the Cordova iOS related source code, I am expecting to see either a simulator's model identifier or the hardware machine which is one of the two items above. When I did a quick test of the source code on a macOS, `x86_64` is returned.
   
   Basically, for an iOS app on a macOS, I am expecting to see the `iOS` platform on a `x86_64` model. I suspect on a Apple Silicon, it would say instead `iOS` platform on an `ARM64`.
   
   I personally think this might be enough, but can anyone explain why it might not be?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] erisu edited a comment on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
erisu edited a comment on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-711471219


   I personally don't see what is the need of this new property. I feel that using both the `device.model` and `device.platform` should be enough to identify what is running on what device. 
   
   To recap from the documents printed in the README of this repo,
   
   `device.platform` should return either `iOS` or `Mac OS X`. But since we are talking about building an iOS app with the Cordova iOS platform, `iOS` will always be returned. This value is hardcoded.
   
   `device.model` should return one of the following two cases:
   
   ```
   // iOS:     for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1
   // OSX:                        returns "x86_64"
   ```
   
   From the Cordova iOS related source code, I am expecting to see either a simulator's model identifier or the hardware machine which is one of the two items above. When I did a quick test of the source code on a macOS, `x86_64` is returned.
   
   Basically, for an iOS app on a macOS, I am expecting to see the `iOS` platform on a `x86_64` model. I suspect on a Apple Silicon, it would say instead `iOS` platform on an `ARM64`.
   
   I personally think this might be enough, but can anyone explain why it might not be?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] SailingSteve edited a comment on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
SailingSteve edited a comment on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-712289784


   This is the object returned by device, when running on Apple Silicon.  (With the additional from this PR).
   
   ```
   2020-10-19 09:28:00.803495-0700 We Vote[1530:17084] Dump Object window.device available: true
   2020-10-19 09:28:00.803554-0700 We Vote[1530:17084] Dump Object window.device platform: iOS
   2020-10-19 09:28:00.803605-0700 We Vote[1530:17084] Dump Object window.device version: 14.0
   2020-10-19 09:28:00.803698-0700 We Vote[1530:17084] Dump Object window.device uuid: 4C9A03D3-4457-5253-8384-B4581A3F7396
   2020-10-19 09:28:00.803778-0700 We Vote[1530:17084] Dump Object window.device cordova: 6.1.1
   2020-10-19 09:28:00.804903-0700 We Vote[1530:17084] Dump Object window.device model: iPad8,9
   2020-10-19 09:28:00.805041-0700 We Vote[1530:17084] Dump Object window.device manufacturer: Apple
   2020-10-19 09:28:00.805150-0700 We Vote[1530:17084] Dump Object window.device isVirtual: false
   2020-10-19 09:28:00.805631-0700 We Vote[1530:17084] Dump Object window.device serial: unknown
   2020-10-19 09:28:00.806016-0700 We Vote[1530:17084] Dump Object window.device isiOSAppOnMac: true
   ```
   Unfortunately 'iPad8,9' matches a real physical device, so it is not usable to detect isiOSAppOnMac condition.
   
   <img width="726" alt="Screen Shot 2020-10-19 at 9 36 37 AM" src="https://user-images.githubusercontent.com/6923653/96480162-bfa3be00-11ee-11eb-884e-6ad3aaee5054.png">
   
   I need access to `isiOSAppOnMac` so that I can tell that the app covers the entire window, and that the hardware menu is not present (Wifi signal, Cell signal, battery, etc).
   
   (Safari DevTools does not work in this window, so all debugging has to rely on the Xcode console.)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] erisu commented on a change in pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
erisu commented on a change in pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#discussion_r840676754



##########
File path: www/device.js
##########
@@ -59,6 +60,7 @@ function Device () {
                 me.cordova = buildLabel;
                 me.model = info.model;
                 me.isVirtual = info.isVirtual;
+                me.isiOSAppOnMac = info.isiOSAppOnMac || false;

Review comment:
       ```suggestion
                   // isiOSAppOnMac is iOS specific. If defined, it will be appended.
                   if (info.isiOSAppOnMac !== undefined) {
                       me.isiOSAppOnMac = info.isiOSAppOnMac;
                   }
   ```
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] erisu edited a comment on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
erisu edited a comment on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-711471219


   I personally don't see what is the need of this new property. I feel that using both the `device.model` and `device.platform` should be enough to identify what device is running the iOS app.
   
   To recap from the documents printed in the README of this repo,
   
   `device.platform` should return either `iOS` or `Mac OS X`. But since we are talking about building an iOS app with the Cordova iOS platform, `iOS` will always be returned. This value is hardcoded.
   
   `device.model` should return one of the following two cases:
   
   ```
   // iOS:     for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1
   // OSX:                        returns "x86_64"
   ```
   
   From the Cordova iOS related source code, I am expecting to see either a simulator's model identifier or the hardware machine which is one of the two items above. When I did a quick test of the source code on a macOS, `x86_64` is returned.
   
   Basically, for an iOS app on a macOS, I am expecting to see the `iOS` platform on a `x86_64` model. I suspect on a Apple Silicon, it would say instead `iOS` platform on an `ARM64`.
   
   I personally think this might be enough, but can anyone explain why it might not be?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] SailingSteve commented on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
SailingSteve commented on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-712289784


   This is the object returned by device, when running on Apple Silicon.  (With the addition in this PR).
   
   ```
   2020-10-19 09:28:00.803495-0700 We Vote[1530:17084] Dump Object window.device available: true
   2020-10-19 09:28:00.803554-0700 We Vote[1530:17084] Dump Object window.device platform: iOS
   2020-10-19 09:28:00.803605-0700 We Vote[1530:17084] Dump Object window.device version: 14.0
   2020-10-19 09:28:00.803698-0700 We Vote[1530:17084] Dump Object window.device uuid: 4C9A03D3-4457-5253-8384-B4581A3F7396
   2020-10-19 09:28:00.803778-0700 We Vote[1530:17084] Dump Object window.device cordova: 6.1.1
   2020-10-19 09:28:00.804903-0700 We Vote[1530:17084] Dump Object window.device model: iPad8,9
   2020-10-19 09:28:00.805041-0700 We Vote[1530:17084] Dump Object window.device manufacturer: Apple
   2020-10-19 09:28:00.805150-0700 We Vote[1530:17084] Dump Object window.device isVirtual: false
   2020-10-19 09:28:00.805631-0700 We Vote[1530:17084] Dump Object window.device serial: unknown
   2020-10-19 09:28:00.806016-0700 We Vote[1530:17084] Dump Object window.device isiOSAppOnMac: true
   ```
   Unfortunately 'iPad8,9' matches a real physical device, so it is not usable to detect isiOSAppOnMac condition.
   
   <img width="726" alt="Screen Shot 2020-10-19 at 9 36 37 AM" src="https://user-images.githubusercontent.com/6923653/96480162-bfa3be00-11ee-11eb-884e-6ad3aaee5054.png">
   
   I need access to `isiOSAppOnMac` so that I can tell that the app covers the entire window, and that the hardware menu is not present (Wifi signal, Cell signal, battery, etc).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] NiklasMerz commented on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
NiklasMerz commented on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-711412026


   Thinking about this again I am confused again. Why would I want to know if the app runs on Apple ARM chips? It should not make a difference if it runs on Mac using Catalyst or natively with ARM, shouldn't it? I may need to know if it runs on desktop or mobile to adjust my styling etc?
   
   Shouldn't the platform return something different if it runs on macOS? Technically it still runs the iOS platform but it's runnig on a Mac using Catalyst or Big Sur.
   
   Other opinions?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-device] erisu edited a comment on pull request #133: (iOS)(Mac Apple Silicon) Detect Cordova running on a Mac desktop with Apple Silicon

Posted by GitBox <gi...@apache.org>.
erisu edited a comment on pull request #133:
URL: https://github.com/apache/cordova-plugin-device/pull/133#issuecomment-711471219


   I personally don't see what is the need of this new property.
   
   I feel that using both the `device.model` and `device.platform` together should be enough to identify if the iOS app is running on a macOS and on which architecture.
   
   To recap from what I am reading and understanding from the documentation written in the repo's README,
   
   The `device.platform` should return either `iOS` or `Mac OS X`. Since we are talking about building an iOS app, which means we are using the Cordova iOS platform, `iOS` will always be returned. This value is hardcoded [here](https://github.com/apache/cordova-plugin-device/blob/master/src/ios/CDVDevice.m#L91).
   
   The `device.model` should return one of the following two cases depending on the device's hardware information:
   
   ```
   // iOS:     for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1
   // OSX:                        returns "x86_64"
   ```
   
   From the Cordova iOS related source code, I am expecting to see either the simulator's model identifier or the hardware machine which is one of the two items above. When running a quick playground test on a macOS, the value `x86_64` is returned.
   
   Basically, I am expecting to see `iOS` platform on a `x86_64` model when running on a macOS. I suspect on an Apple Silicon, it would say `iOS` platform on an `ARM64` model.
   
   I personally think using these two properties combined is enough to know if the app is running on a mac.
   
   Can it be explained why we need to introduce a new property instead of using these two existing properties which already exist and is something that can be used by multiple platforms?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org