Giter Site home page Giter Site logo

Comments (34)

ds300 avatar ds300 commented on May 4, 2024 2

from patch-package.

davidlampon avatar davidlampon commented on May 4, 2024 2

@ds300 Maybe it's because we are behind a private npm repo but we (both of us) only have the chance to install up to 5.1.1. Please, ignore this if we are the only ones reporting the problem.

Update: indeed it was, fixed now by our internal IT team =)
Update2: v6.0.0-3 fixed the white space problem. Thanks!

from patch-package.

lkduerig avatar lkduerig commented on May 4, 2024 1

I was also having this issue. I tried downgrading versions and all kinds of things which didn't work. Removing the cache key and all the lines it included from travis.yml resolved the problem.

Here is the full list of steps I took before reaching this solution:

  • Created patch #1, created pull request, passed Travis tests, merged, patched changes visible on dev server.
  • The patched changes still had a bug, needed to create a new patch. Created patch #2, which included removing the lines added from patch #1 in addition to the changes I needed, rather than a fresh patch on a clean build. Travis tests failed with this error about whitespace.
  • Created patch #3 on a clean install, so the patch included only the lines that would be needed to have the proper fix on a clean build. Travis tests failed with this error about whitespace.
  • Deleted the patch entirely from the patches directory, created a new pull request which passed Travis tests, pull request merged. It did not seem that the undone changes were deployed, so I assumed that Travis must be starting from previous state of node_modules, rather than a fresh install.
  • Sent a new pull request for patch #3, just in case there was a cache or some other issue and the node_modules actually were installed from scratch. Travis failed, same error.
  • Removed the entire cache key from travis.yml, added this change to the previous pull request with patch #3. Voila, tests passed, pull request merged, and updated changes visible.
  • Added the cache key back to travis.yml and made a new pull request.

I think the step to delete the original patch may not have been necessary, but I am not entirely sure. Definitely the step for patch #2 was not useful. I hope any of this helps anyone else having this issue.

from patch-package.

sfratini avatar sfratini commented on May 4, 2024 1

@ds300 I was having the same issue and for now, I can confirm the beta works :)

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks for the report! Hope you don't mind answering a couple more questions:

  1. What's your CI env like? Linux? Git version?
  2. Did you re-create the patch file after downgrading? Or is it the one you made with v5?

from patch-package.

rt2zz avatar rt2zz commented on May 4, 2024
  1. CI i travis, default setup linux. Not sure about git version...
  2. yes, I had to recreate the patch. Specifically here was my proces
    1. upgrade to v5
    2. update patch
    3. CI fail
    4. downgrade to v3
    5. CI still fail
    6. recreate patch
    7. βœ…

Since the patch always applied fine locally, unfortunately I did not have the constitution to debug further on travis. My local git is 2.15

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks for those details. I'm going to look into this over the next week or so. Probably going to end up doing pure-JS patch application if I can. git-apply has been giving me a lot of grief -_-

from patch-package.

rt2zz avatar rt2zz commented on May 4, 2024

cool, I love this package btw! thank you.

FWIW v3 is working great atm

from patch-package.

mauritsd avatar mauritsd commented on May 4, 2024

I think I'm having the same issue, but downgrading to v3 doesn't fix the problem for me:

I get the following error after 'yarn':

**ERROR** Failed to apply patch for package react-native-maps

  This error was caused because Git cannot apply the following patch file:

    patches/react-native-maps+0.19.0.patch

  This is usually caused by inconsistent whitespace in the patch file.

If I manually try to apply the patch with "git apply -v --ignore-whitespace patches/react-native-maps+0.19.0.patch":

Checking patch node_modules/react-native-maps/lib/components/MapView.js.orig...
Checking patch node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMap.m...
Checking patch node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m...
error: while searching for:


@interface AIRGoogleMapManager() <GMSMapViewDelegate>
{
  BOOL didCallOnMapReady;
}

@end


error: patch failed: node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m:32
error: node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m: patch does not apply

If I check AIRGoogleMapManager.m:32 the content it's looking for seems to be there, but it's still failing somehow... If I apply using GNU patch with --ignore-white-space/-l set it does apply (ignore me forgetting to specify it's a unified diff ;-)):

Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|patch-package
|new file mode 100644
|--- /dev/null
|+++ b/node_modules/react-native-maps/lib/components/MapView.js.orig
--------------------------
Patching file node_modules/react-native-maps/lib/components/MapView.js.orig using Plan A...
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- a/node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMap.m
|+++ b/node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMap.m
--------------------------
Patching file node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMap.m using Plan A...
Hunk #1 succeeded at 34.
Hunk #2 succeeded at 50.
Hunk #3 succeeded at 152.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- a/node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m
|+++ b/node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m
--------------------------
Patching file node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapManager.m using Plan A...
Hunk #1 succeeded at 32.
Hunk #2 succeeded at 318.
done

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks for this @mauritsd β€” I should have some time this weekend to take a look at making the patch application js-based rather than using Git, which seems to have quite flaky behaviour across platforms and versions.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

I looked into doing pure-js patch application and I think it would be a lot of work and there would be a bunch of edge cases to deal with, some of which I'm probably not going to anticipate before publishing.

Something I could do to mitigate this problem in the meantime would be to use patch to apply patches on *nix machines and fall back to git apply on windows. For some reason patch seems to be a lot less flaky than git apply

from patch-package.

mauritsd avatar mauritsd commented on May 4, 2024

That'd be fine; I'm also on macOS.

Is there a definitive diagnosis as to why 'git apply' fails? I'll have a look at the patch file and the destination file with a hex editor...

from patch-package.

mauritsd avatar mauritsd commented on May 4, 2024

I've figured out why it fails in my particular instance. When patch-package generates the diff it specifies the --ignore-space-at-eol option to git-diff. Through testing I've found out that this, when coupled with indented lines without content (e.g. " \n"), will cause git-diff to generate patch files which are not accepted by git-apply, even with --ignore-whitespace and friends. If I remove the --ignore-space-at-eol option from patch-package the patch file is a bit less clean but does apply.

Maybe an idea to allow the user to specify which git-diff options to use?

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

from patch-package.

mauritsd avatar mauritsd commented on May 4, 2024

I think the 'right' course of action is to fix git-apply, but that's more of a long term solution...

By the way, git-merge does have an option to ignore spaces at EOL (-Xignore-space-at-eol).

from patch-package.

dinvlad avatar dinvlad commented on May 4, 2024

Same issue here with v5 and CircleCI. Patches appear flaky from one build to another (e.g. it succeeds if I install packages on my local Mac using Yarn with --frozen-lockfile, but the same command fails in Circle). Is there a suggested workaround? Thx

EDIT: the problem reappears even when I regenerate the patch (either via patch-package and diff -u) on a local Linux system.

from patch-package.

dinvlad avatar dinvlad commented on May 4, 2024

Moreover, downgrading to v5.0.0 (which has been working for me for an entire month) does fix the problem. So it seems there might have been some regression in the last 2 releases (5.1.0/5.1.1).

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks for the report. Weird that for you 5.1 is flaky but 5.0 is not. I didn't change the way git apply is invoked except to potentially re-order the cli options. It would be funny if that's causing the issue.

As a temporary workaround you could call patch instead of patch-package in your prepare hook. See the README for an example. I'm planning to make patch-package use it by default soon.

from patch-package.

dinvlad avatar dinvlad commented on May 4, 2024

Hmm, I've just had this problem with 5.0 as well. Updated to 5.1.1 and now it works again! Not sure why it was misbehaving earlier - will update if anything changes again. Thanks

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

πŸ˜‚ 😩 Must find some time to fix this soon. Thanks for the update.

from patch-package.

dinvlad avatar dinvlad commented on May 4, 2024

I think it has something to do with caching of node_modules (that is what I use in CircleCI at least). If yarn.lock hasn't changed, my config will re-use the cached versions of all packages. But if a package was updated, even though I run yarn --frozen-lockfile in CI, it may still update that package without an error. Not sure how this would lead to inconsistency with the applied patch (apart from direct incompatibility with the new version of the package, though I do check that it works on my local system before CI). But purging the cache seems to help (not always though, it seems).

from patch-package.

brunolemos avatar brunolemos commented on May 4, 2024

I'm having this bug. I have 4 old patches that work fine, but the 5th doesn't:

patch-package: Applying patches...
[email protected] βœ”

**ERROR** Failed to apply patch for package react-native-camera

  This error was caused because Git cannot apply the following patch file:

    patches/react-native-camera+1.0.2.patch

  This is usually caused by inconsistent whitespace in the patch file.

Log

See npm log
77 info lifecycle [email protected]~prepare: [email protected]
78 verbose lifecycle [email protected]~prepare: unsafe-perm in lifecycle true
79 verbose lifecycle [email protected]~prepare: PATH: /Users/brunolemos/.npm-global/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/brunolemos/Projects/g2i/app/app-native/node_modules/.bin:/Users/brunolemos/.fastlane/bin:/Users/brunolemos/.rvm/gems/ruby-2.4.0/bin:/Users/brunolemos/.rvm/gems/ruby-2.4.0@global/bin:/Users/brunolemos/.rvm/rubies/ruby-2.4.0/bin:/Users/brunolemos/.rvm/gems/ruby-2.4.0/bin:/Users/brunolemos/.npm-global/bin:/usr/local/bin/mongo/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/brunolemos/Library/Android/sdk//bin:/Users/brunolemos/Library/Android/sdk/platform-tools/:/Users/brunolemos/.rvm/bin
80 verbose lifecycle [email protected]~prepare: CWD: /Users/brunolemos/Projects/g2i/app/app-native
81 silly lifecycle [email protected]~prepare: Args: [ '-c', 'patch-package' ]
82 silly lifecycle [email protected]~prepare: Returned: code: 1  signal: null
83 info lifecycle [email protected]~prepare: Failed to exec prepare script
84 verbose stack Error: [email protected] prepare: `patch-package`
84 verbose stack Exit status 1
84 verbose stack     at EventEmitter.<anonymous> (/Users/brunolemos/.npm-global/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
84 verbose stack     at emitTwo (events.js:126:13)
84 verbose stack     at EventEmitter.emit (events.js:214:7)
84 verbose stack     at ChildProcess.<anonymous> (/Users/brunolemos/.npm-global/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
84 verbose stack     at emitTwo (events.js:126:13)
84 verbose stack     at ChildProcess.emit (events.js:214:7)
84 verbose stack     at maybeClose (internal/child_process.js:925:16)
84 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
85 verbose pkgid [email protected]
86 verbose cwd /Users/brunolemos/Projects/g2i/app/app-native
87 verbose Darwin 17.4.0
88 verbose argv "/usr/local/bin/node" "/Users/brunolemos/.npm-global/bin/npm" "install"
89 verbose node v8.9.0
90 verbose npm  v5.7.1
91 error code ELIFECYCLE
92 error errno 1
93 error [email protected] prepare: `patch-package`
93 error Exit status 1
94 error Failed at the [email protected] prepare script.
94 error This is probably not a problem with npm. There is likely additional logging output above.
95 verbose exit [ 1, true ]

Env

macOS 10.13.3
nodejs 8.9.0
npm 5.7.1
patch-package 5.1.1
react-native 0.54.0
react-native-camera 1.0.2 (pull request)

Patch

See full patch content
patch-package
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorManager.h
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorManager.h
@@ -8,13 +8,17 @@
 
 #import <Foundation/Foundation.h>
 #import <AVFoundation/AVFoundation.h>
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #import <GoogleMobileVision/GoogleMobileVision.h>
 #import <GoogleMVDataOutput/GoogleMVDataOutput.h>
+#endif
+
 
 @protocol RNFaceDetectorDelegate
 - (void)onFacesDetected:(NSArray<NSDictionary *> *)faces;
 @end
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 @interface RNFaceDetectorManager : NSObject
 
 - (NSDictionary *)constantsToExport;
@@ -31,3 +35,4 @@
 - (void)stopFaceDetection;
 
 @end
+#endif
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorManager.m
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorManager.m
@@ -5,6 +5,7 @@
 //  Created by Joao Guilherme Daros Fidelis on 21/01/18.
 //
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #import <React/RCTConvert.h>
 #import "RNCamera.h"
 #import "RNFaceEncoder.h"
@@ -272,3 +273,4 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
 }
 
 @end
+#endif
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorModule.h
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorModule.h
@@ -6,7 +6,9 @@
 //
 
 #import <React/RCTBridgeModule.h>
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #import <GoogleMobileVision/GoogleMobileVision.h>
+#endif
 
 @interface RNFaceDetectorModule : NSObject <RCTBridgeModule>
 @end
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorModule.m
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorModule.m
@@ -5,6 +5,7 @@
 //  Created by Joao Guilherme Daros Fidelis on 21/01/18.
 //
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #import "RNFaceDetectorModule.h"
 #import "RNFaceEncoder.h"
 #import "RNFileSystem.h"
@@ -193,3 +194,4 @@ RCT_EXPORT_METHOD(detectFaces:(nonnull NSDictionary *)options
 }
 
 @end
+#endif
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorUtils.h
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorUtils.h
@@ -5,6 +5,7 @@
 //  Created by Joao Guilherme Daros Fidelis on 21/01/18.
 //
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #import <UIKit/UIKit.h>
 #import <CoreMedia/CoreMedia.h>
 #import <Foundation/Foundation.h>
@@ -33,3 +34,4 @@ typedef NS_ENUM(NSInteger, RNFaceDetectionClassifications) {
 + (CGAffineTransform)transformFromDeviceOutput:(GMVDataOutput *)dataOutput toInterfaceVideoOrientation:(AVCaptureVideoOrientation)interfaceVideoOrientation;
 
 @end
+#endif
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorUtils.m
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceDetectorUtils.m
@@ -5,6 +5,7 @@
 //  Created by Joao Guilherme Daros Fidelis on 21/01/18.
 //
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #import "RNCameraUtils.h"
 #import "RNFaceDetectorUtils.h"
 #import "RNFaceDetectorPointTransformCalculator.h"
@@ -75,3 +76,4 @@ NSString *const RNGMVDataOutputHeightKey = @"Height";
 }
 
 @end
+#endif
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceEncoder.h
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceEncoder.h
@@ -6,6 +6,7 @@
 //
 
 #import <UIKit/UIKit.h>
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #import <GoogleMobileVision/GoogleMobileVision.h>
 
 @interface RNFaceEncoder : NSObject
@@ -15,3 +16,4 @@
 - (NSDictionary *)encode:(GMVFaceFeature *)face;
 
 @end
+#endif
--- a/node_modules/react-native-camera/ios/FaceDetector/RNFaceEncoder.m
+++ b/node_modules/react-native-camera/ios/FaceDetector/RNFaceEncoder.m
@@ -7,6 +7,7 @@
 
 #import "RNFaceEncoder.h"
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #define cDefaultFloatComparisonEpsilon 0.0001
 #define cModEqualFloatsWithEpsilon(dividend, divisor, modulo, epsilon) \
 fabs( fmod(dividend, divisor) - modulo ) < epsilon
@@ -117,3 +118,4 @@ cModEqualFloatsWithEpsilon(dividend, divisor, modulo, cDefaultFloatComparisonEps
 }
 
 @end
+#endif
--- a/node_modules/react-native-camera/ios/RN/RNCamera.m
+++ b/node_modules/react-native-camera/ios/RN/RNCamera.m
@@ -284,6 +284,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     [device unlockForConfiguration];
 }
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 - (void)updateFaceDetecting:(id)faceDetecting
 {
     [_faceDetectorManager setIsEnabled:faceDetecting];
@@ -303,6 +304,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
 {
     [_faceDetectorManager setClassificationsDetected:requestedClassifications];
 }
+#endif
 
 - (void)takePicture:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
 {
@@ -382,7 +384,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
         // At the time of writing AVCaptureMovieFileOutput and AVCaptureVideoDataOutput (> GMVDataOutput)
         // cannot coexist on the same AVSession (see: https://stackoverflow.com/a/4986032/1123156).
         // We stop face detection here and restart it in when AVCaptureMovieFileOutput finishes recording.
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager stopFaceDetection];
+#endif
         [self setupMovieFileCapture];
     }
     
@@ -443,7 +447,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
             self.stillImageOutput = stillImageOutput;
         }
         
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager maybeStartFaceDetectionOnSession:_session withPreviewLayer:_previewLayer];
+#endif
         [self setupOrDisableBarcodeScanner];
         
         __weak RNCamera *weakSelf = self;
@@ -469,7 +475,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     return;
 #endif
     dispatch_async(self.sessionQueue, ^{
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager stopFaceDetection];
+#endif
         [self.previewLayer removeFromSuperlayer];
         [self.session commitConfiguration];
         [self.session stopRunning];
@@ -722,9 +730,12 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     self.videoRecordedReject = nil;
 
     [self cleanupMovieFileCapture];
+
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
     // If face detection has been running prior to recording to file
     // we reenable it here (see comment in -record).
     [_faceDetectorManager maybeStartFaceDetectionOnSession:_session withPreviewLayer:_previewLayer];
+#endif
     
     if (self.session.sessionPreset != AVCaptureSessionPresetHigh) {
         [self updateSessionPreset:AVCaptureSessionPresetHigh];
@@ -738,11 +749,13 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     Class faceDetectorManagerClass = NSClassFromString(@"RNFaceDetectorManager");
     Class faceDetectorManagerStubClass = NSClassFromString(@"RNFaceDetectorManagerStub");
     
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
     if (faceDetectorManagerClass) {
         return [[faceDetectorManagerClass alloc] initWithSessionQueue:_sessionQueue delegate:self];
     } else if (faceDetectorManagerStubClass) {
         return [[faceDetectorManagerStubClass alloc] init];
     }
+#endif
     
     return nil;
 }
--- a/node_modules/react-native-camera/ios/RN/RNCameraManager.m
+++ b/node_modules/react-native-camera/ios/RN/RNCameraManager.m
@@ -86,11 +86,15 @@ RCT_EXPORT_VIEW_PROPERTY(onFacesDetected, RCTDirectEventBlock);
 
 + (NSDictionary *)faceDetectorConstants
 {
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 #if __has_include("RNFaceDetectorManager.h")
     return [RNFaceDetectorManager constants];
 #else
     return [RNFaceDetectorManagerStub constants];
 #endif
+#else
+    return [NSDictionary new];
+#endif
 }
 
 RCT_CUSTOM_VIEW_PROPERTY(type, NSInteger, RNCamera)
new file mode 100644
--- /dev/null
+++ b/node_modules/react-native-camera/ios/RNCamera.xcodeproj/xcuserdata/brunolemos.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>SchemeUserState</key>
+	<dict>
+		<key>RNCamera.xcscheme</key>
+		<dict>
+			<key>orderHint</key>
+			<integer>55</integer>
+		</dict>
+	</dict>
+</dict>
+</plist>
old mode 100644
new mode 100755
old mode 100644
new mode 100755
--- a/node_modules/react-native-camera/src/RNCamera.js
+++ b/node_modules/react-native-camera/src/RNCamera.js
@@ -106,9 +106,9 @@ export default class Camera extends React.Component<PropsType> {
     flashMode: CameraManager.FlashMode,
     autoFocus: CameraManager.AutoFocus,
     whiteBalance: CameraManager.WhiteBalance,
-    faceDetectionMode: CameraManager.FaceDetection.Mode,
-    faceDetectionLandmarks: CameraManager.FaceDetection.Landmarks,
-    faceDetectionClassifications: CameraManager.FaceDetection.Classifications,
+    faceDetectionMode: (CameraManager.FaceDetection || {}).Mode,
+    faceDetectionLandmarks: (CameraManager.FaceDetection || {}).Landmarks,
+    faceDetectionClassifications: (CameraManager.FaceDetection || {}).Classifications,
   };
 
   static propTypes = {
@@ -144,10 +144,10 @@ export default class Camera extends React.Component<PropsType> {
     autoFocus: CameraManager.AutoFocus.on,
     flashMode: CameraManager.FlashMode.off,
     whiteBalance: CameraManager.WhiteBalance.auto,
-    faceDetectionMode: CameraManager.FaceDetection.fast,
+    faceDetectionMode: (CameraManager.FaceDetection || {}).fast,
     barCodeTypes: Object.values(CameraManager.BarCodeType),
-    faceDetectionLandmarks: CameraManager.FaceDetection.Landmarks.none,
-    faceDetectionClassifications: CameraManager.FaceDetection.Classifications.none,
+    faceDetectionLandmarks: ((CameraManager.FaceDetection || {}).Landmarks || {}).none,
+    faceDetectionClassifications: ((CameraManager.FaceDetection || {}).Classifications || {}).none,
     permissionDialogTitle: '',
     permissionDialogMessage: '',
     notAuthorizedView: (
old mode 100644
new mode 100755
old mode 100644
new mode 100755

Investigation

After further investigation, this is the part causing the problem:
See problematic patch content
--- a/node_modules/react-native-camera/ios/RN/RNCamera.m
+++ b/node_modules/react-native-camera/ios/RN/RNCamera.m
@@ -284,6 +284,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     [device unlockForConfiguration];
 }
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 - (void)updateFaceDetecting:(id)faceDetecting
 {
     [_faceDetectorManager setIsEnabled:faceDetecting];
@@ -303,6 +304,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
 {
     [_faceDetectorManager setClassificationsDetected:requestedClassifications];
 }
+#endif
 
 - (void)takePicture:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
 {
@@ -382,7 +384,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
         // At the time of writing AVCaptureMovieFileOutput and AVCaptureVideoDataOutput (> GMVDataOutput)
         // cannot coexist on the same AVSession (see: https://stackoverflow.com/a/4986032/1123156).
         // We stop face detection here and restart it in when AVCaptureMovieFileOutput finishes recording.
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager stopFaceDetection];
+#endif
         [self setupMovieFileCapture];
     }
     
@@ -443,7 +447,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
             self.stillImageOutput = stillImageOutput;
         }
         
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager maybeStartFaceDetectionOnSession:_session withPreviewLayer:_previewLayer];
+#endif
         [self setupOrDisableBarcodeScanner];
         
         __weak RNCamera *weakSelf = self;
@@ -469,7 +475,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     return;
 #endif
     dispatch_async(self.sessionQueue, ^{
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager stopFaceDetection];
+#endif
         [self.previewLayer removeFromSuperlayer];
         [self.session commitConfiguration];
         [self.session stopRunning];
@@ -722,9 +730,12 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     self.videoRecordedReject = nil;
 
     [self cleanupMovieFileCapture];
+
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
     // If face detection has been running prior to recording to file
     // we reenable it here (see comment in -record).
     [_faceDetectorManager maybeStartFaceDetectionOnSession:_session withPreviewLayer:_previewLayer];
+#endif
     
     if (self.session.sessionPreset != AVCaptureSessionPresetHigh) {
         [self updateSessionPreset:AVCaptureSessionPresetHigh];
@@ -738,11 +749,13 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     Class faceDetectorManagerClass = NSClassFromString(@"RNFaceDetectorManager");
     Class faceDetectorManagerStubClass = NSClassFromString(@"RNFaceDetectorManagerStub");
     
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
     if (faceDetectorManagerClass) {
         return [[faceDetectorManagerClass alloc] initWithSessionQueue:_sessionQueue delegate:self];
     } else if (faceDetectorManagerStubClass) {
         return [[faceDetectorManagerStubClass alloc] init];
     }
+#endif
     
     return nil;
 }

You can compare with the pull request and see some numbers are off.

from patch-package.

brunolemos avatar brunolemos commented on May 4, 2024

I made the changes again on the file above, this time it decided to work πŸ€”
The difference between the new and old patches are indeed only spaces:

screenshot

See new generated patch
--- a/node_modules/react-native-camera/ios/RN/RNCamera.m
+++ b/node_modules/react-native-camera/ios/RN/RNCamera.m
@@ -284,6 +284,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     [device unlockForConfiguration];
 }
 
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
 - (void)updateFaceDetecting:(id)faceDetecting
 {
     [_faceDetectorManager setIsEnabled:faceDetecting];
@@ -303,6 +304,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
 {
     [_faceDetectorManager setClassificationsDetected:requestedClassifications];
 }
+#endif
 
 - (void)takePicture:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
 {
@@ -382,7 +384,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
         // At the time of writing AVCaptureMovieFileOutput and AVCaptureVideoDataOutput (> GMVDataOutput)
         // cannot coexist on the same AVSession (see: https://stackoverflow.com/a/4986032/1123156).
         // We stop face detection here and restart it in when AVCaptureMovieFileOutput finishes recording.
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager stopFaceDetection];
+#endif
         [self setupMovieFileCapture];
     }
     
@@ -443,7 +447,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
             self.stillImageOutput = stillImageOutput;
         }
         
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager maybeStartFaceDetectionOnSession:_session withPreviewLayer:_previewLayer];
+#endif
         [self setupOrDisableBarcodeScanner];
         
         __weak RNCamera *weakSelf = self;
@@ -469,7 +475,9 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     return;
 #endif
     dispatch_async(self.sessionQueue, ^{
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
         [_faceDetectorManager stopFaceDetection];
+#endif
         [self.previewLayer removeFromSuperlayer];
         [self.session commitConfiguration];
         [self.session stopRunning];
@@ -722,9 +730,11 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     self.videoRecordedReject = nil;
     
     [self cleanupMovieFileCapture];
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
     // If face detection has been running prior to recording to file
     // we reenable it here (see comment in -record).
     [_faceDetectorManager maybeStartFaceDetectionOnSession:_session withPreviewLayer:_previewLayer];
+#endif
     
     if (self.session.sessionPreset != AVCaptureSessionPresetHigh) {
         [self updateSessionPreset:AVCaptureSessionPresetHigh];
@@ -738,11 +748,13 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
     Class faceDetectorManagerClass = NSClassFromString(@"RNFaceDetectorManager");
     Class faceDetectorManagerStubClass = NSClassFromString(@"RNFaceDetectorManagerStub");
     
+#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
     if (faceDetectorManagerClass) {
         return [[faceDetectorManagerClass alloc] initWithSessionQueue:_sessionQueue delegate:self];
     } else if (faceDetectorManagerStubClass) {
         return [[faceDetectorManagerStubClass alloc] init];
     }
+#endif
     
     return nil;
 }

How to prevent this from happening again?

from patch-package.

dinvlad avatar dinvlad commented on May 4, 2024

FWIW, not sure if the same could be done in Travis, but in CircleCI it's easy enough to update the cache key by just adding a number to it, like so:

- restore_cache:
    keys:
      - cache-{{ checksum "yarn.lock" }}-1
      - cache-

One can always just increment the number if the cache key needs to be busted again. Hope that helps.

from patch-package.

lkduerig avatar lkduerig commented on May 4, 2024

I'll keep that in mind next time around, thanks for the tip @dinvlad.

I hope this issue finds a solution, this is an incredibly useful module. @ds300 , thanks so much for the great work on this!

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Another update for this thread: You can try out the 6.0.0-X pre-release builds, which use the new TS-only patch application (yay! no more git apply πŸŽ‰). It should fix these errors in 99.9% of cases. I have a few more bits to iron out before making a full release. You can follow progress in #45

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Oh no. Apparently the publish didn't go through last night. Should work now.

npm i --save-dev patch-package@beta

or

yarn add --dev patch-package@beta

from patch-package.

davidlampon avatar davidlampon commented on May 4, 2024

@ds300 The @beta is pointing to this version (and I guess the good one is v6.0.0-3):

https://github.com/ds300/patch-package/releases/tag/v3.5.3-0

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Weird, for me it's pointing to the correct one, v6.0.0-3

image

image

Are you using yarn or npm?

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Also this:
image

from patch-package.

DanielRuf avatar DanielRuf commented on May 4, 2024

Is this fixed and can it be closed?

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Yes! It is fixed in patch-package@beta. Need to find some time to push out a full release soon. Might as well close this now though, since it's not tied to a specific issue but a kind of genre of issues that I don't have to worry about any more :)

from patch-package.

pstanton avatar pstanton commented on May 4, 2024

i'm getting the same with a patch that was supposedly working for over a month, nothing updated that i know of...

v5.1.1

from patch-package.

JoschaP avatar JoschaP commented on May 4, 2024

This problem also occurs when someone creates a patch with npm/npx and his colleague tries to apply the patch with Yarn..

Maybe we can implement a notice for such a human problems in the fail message?

from patch-package.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.