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 2021/09/27 19:43:00 UTC

[GitHub] [cordova-plugin-media] giteshpatil opened a new issue #314: File Size coming as 0 in android 11

giteshpatil opened a new issue #314:
URL: https://github.com/apache/cordova-plugin-media/issues/314


   # Bug Report
   On Android below 11 works fine and size also comes perfect but on android 11 size always comes as 0
   ## Problem
   
   ### What is expected to happen?
   It should record the file and should be able to show file size more than 0
   
   
   ### What does actually happen?
   Not working in android 11
   
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   Any more information needed please feel free to ask.
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   recordAudio(){
     let extension ='wav'  // 'm4a' 'mp3'
       
     this.file.createFile(this.file.dataDirectory, '111file.'+extension, true).then(() => {
     this.myFile = this.media.create(this.file.dataDirectory+'111file.'+extension,);
     console.log('filepath',this.file.dataDirectory+'111file.'+extension)
     console.log("this.myFile",this.myFile)
     this.myFile.startRecord();
     alert('started recording')
   }).catch(err=>{
     console.log('createFile err',err)
   }); 
   
   
   async stopRecording(){
     let extension = 'wav'// 'm4a' 'mp3'
     alert('stop called')
     this.myFile.stopRecord()
    
     setTimeout(() => {
     let duration = this.myFile.getDuration();
     console.log(duration);
     console.log("this.myFile2",this.myFile)
   
     this.file.readAsDataURL(this.file.dataDirectory, '111file.'+extension).then(res=>{
       console.log("checkFile res",res)
       let url = this.file.dataDirectory+'111file.'+extension
       this.file.resolveLocalFilesystemUrl(url).then(fileEntry => {
         fileEntry.getMetadata((metadata) => {       
        console.log("size",metadata.size);//metadata.size is the size in bytes
       })
       })
     }).catch(err=>{
       console.log("checkFile err",err)
     })
   }, 1000);
   }
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   Device used: Oneplus 9R
   OS: Android 11
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   Project based on ionic 3
   cordova  10.0.0
   ionic 5.4.13
   "cordova-plugin-file": "^6.0.2",
   "cordova-android": "8.1.0",
   "@ionic-native/media": "^4.20.0",
   "cordova-plugin-media": "^5.0.3",
   "typescript": "2.8.4"
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x ] I searched for existing GitHub issues
   - [x ] I updated all Cordova tooling to most recent version
   - [x ] I included all the necessary information above
   


-- 
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-media] rozpuszczalny commented on issue #314: File Size coming as 0 in android 11

Posted by GitBox <gi...@apache.org>.
rozpuszczalny commented on issue #314:
URL: https://github.com/apache/cordova-plugin-media/issues/314#issuecomment-984693241


   Looks like it's fixed by #317 . Personally, I've installed cordova-plugin-media directly from GitHub by doing this: `npm i --save apache/cordova-plugin-media#4093f7e` (4093f7e is the latest commit so far on master branch)


-- 
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-media] breautek commented on issue #314: File Size coming as 0 in android 11

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #314:
URL: https://github.com/apache/cordova-plugin-media/issues/314#issuecomment-934115631


   Thanks for the investigation @sc0ttdav3y 
   
   This matches my findings, the external root directory `/storage/emulated/0/` (or it may be a `/sdcard` path if your device has a real external storage) is no longer writable starting in API 29/30. API offered an escape hatch, but today you must target API 30.
   
   The problematic line is 
   
   https://github.com/apache/cordova-plugin-media/blob/e29fcc6355d8a07413feea46fcc78f05b78ce52f/src/android/AudioPlayer.java#L112
   
   If external media is mounted (which virtually all phones have external media due to emulation, hence the `/storage/emulated` name), it will attempt to write to it's root directory.
   
   Personally, I'm not sure on the original rationale. We should never write to an external medium unless explicitly requested.


-- 
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-media] rozpuszczalny edited a comment on issue #314: File Size coming as 0 in android 11

Posted by GitBox <gi...@apache.org>.
rozpuszczalny edited a comment on issue #314:
URL: https://github.com/apache/cordova-plugin-media/issues/314#issuecomment-984693241


   Looks like it's fixed by #317. Personally, I've installed `cordova-plugin-media` directly from GitHub by doing this: `npm i --save apache/cordova-plugin-media#4093f7e` (4093f7e is the latest commit so far on master branch)


-- 
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-media] sc0ttdav3y commented on issue #314: File Size coming as 0 in android 11

Posted by GitBox <gi...@apache.org>.
sc0ttdav3y commented on issue #314:
URL: https://github.com/apache/cordova-plugin-media/issues/314#issuecomment-934133334


   I've got a local working solution for Android 11, and linked a draft PR for your review: 
   https://github.com/apache/cordova-plugin-media/pull/316
   
   I don't have the capacity to test this across lots of devices and OSs, so I can't check all the PR boxes.


-- 
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-media] sc0ttdav3y commented on issue #314: File Size coming as 0 in android 11

Posted by GitBox <gi...@apache.org>.
sc0ttdav3y commented on issue #314:
URL: https://github.com/apache/cordova-plugin-media/issues/314#issuecomment-934094029


   I've got this too. 
   
   I believe it's related to changes to Android's new filesystem permissions in 11. 
   https://developer.android.com/training/data-storage/use-cases#opt-out-scoped-storage
   
   See this long thread over at https://github.com/apache/cordova-plugin-file/issues/426 for some info on how other plugins are battling it out:
   
   
   I haven't found a solution yet but I'll add some info here if I find anything. Others have been juggling the API version to work around it but that's no longer an option for those publishing to Google Play.
   
   Here's relevant logging info from `adb logcat` that may be of use to the plugin maintainers. The main errors seem to be:
   
   ```
   MediaProvider: java.lang.IllegalArgumentException: Primary directory null not allowed for content://media/external_primary/file; allowed directories are [Download, Documents]
   ```
   
   and 
   
   ```
   System.err: java.io.FileNotFoundException: /storage/emulated/0/tmprecording-1633411896974.3gp: open failed: EPERM (Operation not permitted)
   ```
   
   Here's the full log:
   
   ```
   MediaRecorder: Constructor MediaRecorder
   MediaRecorderJNI: setup
   StagefrightRecorder: property set(service.camera.rec.running, 0) result = 0
   MediaPlayerService: Create new media recorder client from pid 27788
   RestrictionPolicy: userId: 0, isMicrophoneEnabledAsUser : true
   MediaRecorderJNI: setAudioSource(1)
   MediaRecorderJNI: setAudioEncoder(3)
   RestrictionPolicy: userId: 0, isMicrophoneEnabledAsUser : true
   RestrictionPolicy: userId: 0 isAudioRecordAllowed : true
   MediaProvider: insertFileIfNecessary failed
   MediaProvider: java.lang.IllegalArgumentException: Primary directory null not allowed for content://media/external_primary/file; allowed directories are [Download, Documents]
   MediaProvider: 	at com.android.providers.media.MediaProvider.ensureFileColumns(MediaProvider.java:2932)
   MediaProvider: 	at com.android.providers.media.MediaProvider.ensureUniqueFileColumns(MediaProvider.java:2597)
   MediaProvider: 	at com.android.providers.media.MediaProvider.insertFile(MediaProvider.java:3291)
   MediaProvider: 	at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:3844)
   MediaProvider: 	at com.android.providers.media.MediaProvider.insert(MediaProvider.java:3555)
   MediaProvider: 	at com.android.providers.media.MediaProvider.insertFileForFuse(MediaProvider.java:7199)
   MediaProvider: 	at com.android.providers.media.MediaProvider.insertFileIfNecessaryForFuse(MediaProvider.java:7293)
   System.err: java.io.FileNotFoundException: /storage/emulated/0/tmprecording-1633411896974.3gp: open failed: EPERM (Operation not permitted)
   System.err: 	at libcore.io.IoBridge.open(IoBridge.java:492)
   System.err: 	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:289)
   System.err: 	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:152)
   System.err: 	at android.media.MediaRecorder.prepare(MediaRecorder.java:1417)
   System.err: 	at org.apache.cordova.media.AudioPlayer.startRecording(AudioPlayer.java:161)
   System.err: 	at org.apache.cordova.media.AudioHandler.startRecordingAudio(AudioHandler.java:287)
   System.err: 	at org.apache.cordova.media.AudioHandler.promptForRecord(AudioHandler.java:543)
   System.err: 	at org.apache.cordova.media.AudioHandler.execute(AudioHandler.java:118)
   System.err: 	at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
   System.err: 	at org.apache.cordova.PluginManager.exec(PluginManager.java:139)
   System.err: 	at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
   System.err: 	at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
   System.err: 	at android.os.MessageQueue.nativePollOnce(Native Method)
   System.err: 	at android.os.MessageQueue.next(MessageQueue.java:335)
   System.err: 	at android.os.Looper.loop(Looper.java:206)
   System.err: 	at android.os.HandlerThread.run(HandlerThread.java:67)
   System.err: Caused by: android.system.ErrnoException: open failed: EPERM (Operation not permitted)
   System.err: 	at libcore.io.Linux.open(Native Method)
   System.err: 	at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
   System.err: 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
   System.err: 	at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
   System.err: 	at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8448)
   System.err: 	at libcore.io.IoBridge.open(IoBridge.java:478)
   System.err: 	... 15 more
   PluginManager: THREAD WARNING: exec() call to Media.startRecordingAudio blocked the main thread for 35ms. Plugin should use CordovaInterface.getThreadPool().
   chromium: [INFO:CONSOLE(406)] "recordAudio():Audio Error [object Object]", source: http://localhost:8080/app.js (406)
   ```
   


-- 
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-media] spinybeast commented on issue #314: File Size coming as 0 in android 11

Posted by GitBox <gi...@apache.org>.
spinybeast commented on issue #314:
URL: https://github.com/apache/cordova-plugin-media/issues/314#issuecomment-969949618


   any updates of this? have same problem


-- 
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