gre / gl-react

gl-react – React library to write and compose WebGL shaders
https://gl-react-cookbook.surge.sh
MIT License
2.94k stars 163 forks source link

How to capture effected image and save it to file? #93

Closed kesha-antonov closed 4 years ago

kesha-antonov commented 7 years ago

Hello!

In v2 we've had captureFrame function. https://github.com/ProjectSeptemberInc/gl-react-native/blob/cf77646239ee1c9d6002c28cb8864cb65d2de898/src/GLCanvas.js#L55

But there is no such function in "v3", right? Or I can save image with capture() somehow?

Please help.

I've asked something similar in "v2" repo: https://github.com/ProjectSeptemberInc/gl-react-native/issues/96

question

library version: gl-react/next + gl-react-native/next

gl-react@3.0.0-alpha.6
gl-react-native@3.0.0-alpha.6

Expected behavior

Expected to find some simple function to call and save effected image to file in cache directory

refs.surface.captureFrame({
       type: 'jpg'
       format: 'file'
       quality: 1
       filePath: "#{RNFS.DocumentDirectoryPath}/#{new Date().getTime()}.jpg"
}).then((newImageUri) =>
 ....

Actual behavior

this.refs.surface.capture()

returns array of pixels (right?)

gre commented 7 years ago

That's a good point, this function don't exist yet and I should figure out the best way to add it back. I need to think a bit what would be the best way for that, but what you can do at the moment is capture() that should returns a "ndarray" which is basically an object with a data (Uint32array of pixels) and a shape that your image [width,height,4]. But it would not be trivial nor efficient to try to re-encode that to image on JS thread. So I think I need to add something on the implementation.

The web version have captureAsDataURL and captureAsBlob because it's easier to solve that as there are Web API to do that (canvas.toDataURL & canvas.toBlob).

gre commented 7 years ago

a workaround might be to try to use https://github.com/gre/react-native-view-shot for now (I think it only works in iOS tho – regarding a GL view)

kesha-antonov commented 7 years ago

Thanks! I'll try https://github.com/gre/react-native-view-shot It can work for me if that package can save image in a good quality (for photos) 2000x1000 px for example

gre commented 7 years ago

actually i'm afraid there is also this issue opened and I can't figure out why :'( https://github.com/gre/react-native-view-shot/issues/50

kesha-antonov commented 7 years ago

@gre What do you think about this issue? Can you help with it or I can make same changes (https://github.com/gre/gl-react/commit/93763144f610a3291a2e5747ab3c649890539a8f) in gl-react-native v2 and use it to capture effected image for now.

gre commented 7 years ago

gl-react-native v2 don't have the issue, I think the pixel ratio is already correct in v2.

gre commented 7 years ago

I think the issue is solvable but I'm not sure the best way to implement. I'm trying to think a nice way to solve it generically and minimize the implementation involved, but probably it's not really possible.. Anyway, basically it will require some more code on both iOS and Android modules.

kesha-antonov commented 7 years ago

@gre Maybe I'm mistaken but v2 does have "blurred image" issue. That's why I switched to v3 with hope to not find that here.

gre commented 7 years ago

Did setting a pixelRatio helped? in v2 there were this concept of pixelRatio – e.g <Surface pixelRatio={2} ...>

gre commented 7 years ago

(which by default was supposed to be set to the device pixel ratio size..)

kesha-antonov commented 7 years ago

Oh. Missed that. I'll try. Thanks!

Anyway if you'll have time to implement "capture" in v3 it would really-really cool! Since I would like to use gl-react to effect Videos too and v2 will not have new features I guess it's better to use v3.

kesha-antonov commented 7 years ago

Maybe something like this can work? http://stackoverflow.com/questions/7650144/how-to-convert-bytearray-to-image-in-objective-c http://stackoverflow.com/questions/11860830/byte-array-to-nsdata

I'll have time tomorrow and can try it

gre commented 7 years ago

yeah, I guess it could even be a generic library that you send the native array from JS and convert it back.

but maybe it would be more performant if it was made as a method from inside EXGLView. i'm not sure how easy it is.

gre commented 7 years ago

basically I imagine something like this:

JS side, call a function like EXGLView.capture(viewTag) -> EXGLViewManager.capture static method will resolve viewTag to a EXGLView and call capture on it -> EXGLView.capture needs to run something on the correct thread. I'm not exactly sure what to run (gl.readPixels is meant for JS, maybe there is a smarter way to get pixels directly). also i'm not sure what's the correct thread for that. and how to get it back to JS. (where does it save, basically)

Ideally it could take the same options of that lib https://github.com/gre/react-native-view-shot#takesnapshotview-options

kesha-antonov commented 7 years ago

Hello @gre ! Have you had time to experiment with EXGLView?

gre commented 7 years ago

just want to tell you I did not forget about this task, in term of priority scheduling i'm waiting the release of an incoming version of EXGLView that will allow to do more things around texture & stuff.

kesha-antonov commented 7 years ago

Hey! Thanks!

Yeah, it would be cool!

kesha-antonov commented 7 years ago

Hey @gre

What's the best way to try do it with objective-c/java ?

1) Make function "capture" in gl-react-native 2) Call from function "1" this function https://github.com/gre/gl-react/blob/master/packages/gl-react/src/Node.js#L547 3) Call native libs for ios/android and send them array from "2" 4) Convert byte array of pixels to image and save image in temp 5) Return image uri

Is this correct? I want to try it tomorrow

kesha-antonov commented 7 years ago
JS side, call a function like EXGLView.capture(viewTag) -> EXGLViewManager.capture static method will resolve viewTag to a EXGLView

What is viewTag ?

kesha-antonov commented 7 years ago

Ok. I can write "save pixels to new image". But first I'm trying to understand how to get "viewTag" and how to get EXGLView from it.

I'm thinking of putting UUID here https://github.com/gre/gl-react/blob/master/packages/gl-react-native/android/src/main/java/fr/greweb/rngl/EXGLView.java#L44 Then return it in "onSurfaceCreate"

Then call EXGLView.capture(viewTag) -> EXGLViewManager.capture

Is it correct? I'm just guessing here

kesha-antonov commented 7 years ago

Ok. I think viewTag is this.refs.surface.gl or this.refs.surface.glView. Correct ?

kesha-antonov commented 7 years ago

More thoughts: "Capture screen of GLSurfaceView to bitmap" 1) http://stackoverflow.com/questions/5514149/capture-screen-of-glsurfaceview-to-bitmap 2) https://github.com/CyberAgent/android-gpuimage/blob/master/library/src/jp/co/cyberagent/android/gpuimage/GPUImage.java#L281

kesha-antonov commented 7 years ago

What if we will take this.refs.surface.gl and call native code: 1) EXGLView.js: EXGLView.captureFrame(0, 0, 1000, 1000, this.refs.surface.gl) 2) -> EXGLViewManager.java: createBitmapFromGLSurface(0, 0, 1000, 1000, gl)

?

kesha-antonov commented 7 years ago

Ok. I'm started working on it:

https://github.com/gre/gl-react/compare/master...kesha-antonov:capture_frame_from_gl

But I'm not sure how to pass or resolve gl here.

Do you have some advices?

gre commented 7 years ago

maybe see how i did it in https://github.com/gre/react-native-view-shot ?

kesha-antonov commented 7 years ago

Cool! Thanks. Will try that

kesha-antonov commented 7 years ago

Ok. I've experimented a little bit more in another brunch but I'm stuck now because of lack of knowledge https://github.com/gre/gl-react/compare/master...kesha-antonov:capture_frame_from_gl-1

Will back here later

gre commented 7 years ago

this might help: https://github.com/ProjectSeptemberInc/gl-react-native/blob/master/android/src/main/java/com/projectseptember/RNGL/GLCanvas.java#L874-L899

kesha-antonov commented 7 years ago

Yes, this is what i'm trying to achieve. Maybe we can port that function in v3?

kesha-antonov commented 7 years ago

Trying to do capture with https://github.com/gre/react-native-view-shot : black screen

Trying do capture with v2: running out of memory for images 3000x3000 https://github.com/ProjectSeptemberInc/gl-react-native/issues/151

kesha-antonov commented 7 years ago
screen shot 2017-05-12 at 21 01 35 screen shot 2017-05-12 at 21 00 42
gre commented 7 years ago

I'm afraid there is an Android limitation that you can't create a bitmap bigger than the pixel device size 😥

Maybe there is a workaround to generate an image without using bitmap?

kesha-antonov commented 7 years ago

Max size for Surface is Dimensions.get('window').width * PixelRatio.get()xDimensions.get('window').height * PixelRatio.get() ? Otherwise it will throw error?

gre commented 7 years ago

I have not tested but I guess Surface still works above this size but probably not creating a Bitmap out of it? not sure

kesha-antonov commented 7 years ago

It throws (crashes) here when I try to render 4000x4000 Surface

https://github.com/ProjectSeptemberInc/gl-react-native/blob/master/android/src/main/java/com/projectseptember/RNGL/GLCanvas.java#L828

kesha-antonov commented 7 years ago

It crashes everything so It's good to know what max size is appropriate for GLCanvas/Surface

05-14 11:50:48.072  1473  1743 D GpsStatusListenerHelper: Remote Listener died: android.location.IGpsStatusListener$Stub$Proxy@1113301
05-14 11:50:48.083  1473  2084 I ActivityManager: Process com.google.android.gms.persistent (pid 26340) has died
05-14 11:50:48.083  1473  2084 D ActivityManager: cleanUpApplicationRecord -- 26340
05-14 11:50:48.092  1473  1657 D WifiService: Client connection lost with reason: 4
05-14 11:50:48.108   453   453 E lowmemorykiller: Error writing /proc/26277/oom_score_adj; errno=22
05-14 11:50:48.137  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/com.google.location.nearby.direct.service.NearbyDirectService in 1000ms
05-14 11:50:48.144  1473  1657 D WifiService: Client connection lost with reason: 4
05-14 11:50:48.144  1968  1968 I WhetstoneProvider_PersistManager: I MyServiceConnection onServiceDisconnected:ComponentInfo{com.miui.powerkeeper/com.miui.powerkeeper.PowerKeeperBackgroundService}
05-14 11:50:48.145  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/com.google.android.contextmanager.service.ContextManagerService in 1000ms
05-14 11:50:48.146  1473  2392 D PowerKeeperPolicy: powerkeeper died, reset handle to null
05-14 11:50:48.146  1473  2392 D PowerKeeperPolicy: restore miui gps status
05-14 11:50:48.148  1968  1968 I WhetstoneProvider_PersistManager: I MyServiceConnection onServiceDisconnected info:Comp:ComponentInfo{com.miui.powerkeeper/com.miui.powerkeeper.PowerKeeperBackgroundService},hasConnected:true,rstart:true,autoStart:true
05-14 11:50:48.149  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/.nearby.messages.service.NearbyMessagesService in 109164ms
05-14 11:50:48.152  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/.gcm.GcmService in 119161ms
05-14 11:50:48.154  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/.auth.trustagent.GoogleTrustAgent in 129158ms
05-14 11:50:48.157  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/.clearcut.service.ClearcutLoggerService in 139156ms
05-14 11:50:48.159  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/com.google.android.location.internal.server.GoogleLocationService in 149155ms
05-14 11:50:48.161  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/.auth.setup.devicesignals.LockScreenService in 159153ms
05-14 11:50:48.164  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/com.google.android.location.internal.GoogleLocationManagerService in 169150ms
05-14 11:50:48.166  1473  2084 W ActivityManager: Scheduling restart of crashed service com.google.android.gms/com.google.android.location.internal.PendingIntentCallbackService in 179148ms
05-14 11:50:48.167  1473  2084 E JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 96)
05-14 11:50:48.186  1473  1491 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ id=47, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], android.os.BinderProxy@5a335a6)
05-14 11:50:48.329  1473  1658 D ConnectivityService: releasing NetworkRequest NetworkRequest [ id=47, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
05-14 11:50:48.332  2653  2653 D QC_RIL_OEM_HOOK: The connection to the service got disconnected unexpectedly!
05-14 11:50:48.332  2653  2653 D QC_RIL_OEM_HOOK: Calling onQcRilHookDisconnected callback
05-14 11:50:48.334  1473  1657 D WifiService: Client connection lost with reason: 4
05-14 11:50:48.344  2851  2851 I URLFilterManager: on GPService DisConnected
05-14 11:50:48.345  1473  2392 E IPCThreadState: binder thread pool (15 threads) starved for 144 ms
05-14 11:50:48.375  1473  2126 V SplashScreenServiceDelegate: SplashScreen service binderDied!
05-14 11:50:48.375  1473  2126 V SplashScreenServiceDelegate: restart service delay time 20000
05-14 11:50:48.375  1473  2126 V SplashScreenServiceDelegate: splashscreen service rebind count: 1
05-14 11:50:48.375  1473  1473 V SplashScreenServiceDelegate: SplashScreen service disconnected!
05-14 11:50:48.392   454   454 I ServiceManager: service 'com.qti.snapdragon.sdk.display.IColorService' died
05-14 11:50:48.406  2653  2653 D QC_RIL_OEM_HOOK: The connection to the service got disconnected unexpectedly!
05-14 11:50:48.406  2653  2653 D QC_RIL_OEM_HOOK: Calling onQcRilHookDisconnected callback
05-14 11:50:48.411  1473  1680 D RttService: ClientHandler got{ when=-25ms what=69636 arg1=4 obj=com.android.internal.util.AsyncChannel@6e67ffc target=com.android.server.wifi.RttService$RttServiceImpl$ClientHandler }
05-14 11:50:48.411  1473  1680 D RttService: Client connection lost with reason: 4
05-14 11:50:48.419  1473  1680 D RttService: closing client android.os.Messenger@40b7685
05-14 11:50:48.465  2653  2653 D QC_RIL_OEM_HOOK: The connection to the service got disconnected unexpectedly!
05-14 11:50:48.465  2653  2653 D QC_RIL_OEM_HOOK: Calling onQcRilHookDisconnected callback
05-14 11:50:48.477  1473  1765 I ActivityManager: Process com.miui.powerkeeper:service (pid 26362) has died
05-14 11:50:48.477  1473  1765 D ActivityManager: cleanUpApplicationRecord -- 26362
05-14 11:50:48.480  1473  1765 W ActivityManager: Scheduling restart of crashed service com.miui.powerkeeper/.PowerKeeperBackgroundService in 178833ms
05-14 11:50:48.486  1473  1765 W ActivityManager: Scheduling restart of crashed service com.miui.powerkeeper/.pushaligpolicy.PushHBAligPolicyService in 188827ms
05-14 11:50:48.488   682   799 D ThermalEngine: sensor_wait: case_therm Wait done.
05-14 11:50:48.490   682   799 D ThermalEngine: sensor_monitor: case_therm Reading 41000 .
05-14 11:50:48.490   682   799 I ThermalEngine: Sensor:case_therm:41000 mC
05-14 11:50:48.490   682   799 D ThermalEngine: update_active_thresh: case_therm Active(1), Hi(1) 42000, Lo(0) -2147483648, Interval(1) 1000
05-14 11:50:48.490   682   799 D ThermalEngine: sensor_monitor: case_therm Sensor wait.
05-14 11:50:48.490   682   799 D ThermalEngine: sensor_wait: case_therm Wait start. 1000ms
05-14 11:50:48.492  3333  3403 I octvm_whetstone: mcd: can't request the same  mode continuously
05-14 11:50:48.493  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.493  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.493  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.496  1473  1765 W ActivityManager: Scheduling restart of crashed service com.miui.powerkeeper/.powerchecker.PowerCheckerService in 198818ms
05-14 11:50:48.498 28848 28880 W dex2oat : Compilation of android.database.Cursor com.google.android.music.store.MusicContentProvider.query(com.google.android.music.store.MusicContentQuery, com.google.android.music.store.MusicContentQueryState) took 193.144ms
05-14 11:50:48.501  1473  2021 I ActivityManager: Process com.google.android.gms (pid 26277) has died
05-14 11:50:48.502  1473  2021 D ActivityManager: cleanUpApplicationRecord -- 26277
05-14 11:50:48.505 28990 28990 W System  : ClassLoader referenced unknown path: /system/priv-app/MiuiHome/lib/arm64
05-14 11:50:48.505  1473  2392 I ActivityManager: Process com.miui.guardprovider (pid 28386) has died
05-14 11:50:48.505  1473  2392 D ActivityManager: cleanUpApplicationRecord -- 28386
05-14 11:50:48.506  2534  2534 D QtiGbaAuthService: gba module disconnected
05-14 11:50:48.506  3333 17608 I octvm_whetstone: mcd: can't request the same  mode continuously
05-14 11:50:48.511  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.511  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.511  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.514  1473  1658 E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=47, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
05-14 11:50:48.515  3333  3333 I octvm_whetstone: mcd: can't request the same  mode continuously
05-14 11:50:48.515 29002 29002 W System  : ClassLoader referenced unknown path: /system/priv-app/Settings/lib/arm64
05-14 11:50:48.515  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.515  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.515  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.518  1473  2392 W ActivityManager: Scheduling restart of crashed service com.miui.guardprovider/.manager.SecurityService in 138794ms
05-14 11:50:48.522  1473  2082 I ActivityManager: Process com.miui.systemAdSolution (pid 26188) has died
05-14 11:50:48.522  1473  2082 D ActivityManager: cleanUpApplicationRecord -- 26188
05-14 11:50:48.526  3333  3403 I octvm_whetstone: mcd: can't request the same  mode continuously
05-14 11:50:48.526  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.526  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.526  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.528  1473  2082 W ActivityManager: Scheduling restart of crashed service com.miui.systemAdSolution/com.xiaomi.ad.internal.server.WakeupService in 208786ms
05-14 11:50:48.530  1473  2082 W ActivityManager: Scheduling restart of crashed service com.miui.systemAdSolution/.splashscreen.SplashScreenService in 218784ms
05-14 11:50:48.533  1473  2027 I ActivityManager: Process com.android.defcontainer (pid 27001) has died
05-14 11:50:48.533  1473  2027 D ActivityManager: cleanUpApplicationRecord -- 27001
05-14 11:50:48.535  1473  2027 W ActivityManager: Scheduling restart of crashed service com.android.defcontainer/.DefaultContainerService in 228778ms
05-14 11:50:48.537  1473  2124 I ActivityManager: Process com.qualcomm.qcrilmsgtunnel (pid 26872) has died
05-14 11:50:48.537  1473  2124 D ActivityManager: cleanUpApplicationRecord -- 26872
05-14 11:50:48.538  3333 17608 I octvm_whetstone: mcd: can't request the same  mode continuously
05-14 11:50:48.538  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.538  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.538  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.550  1473  2124 W ActivityManager: Scheduling restart of crashed service com.qualcomm.qcrilmsgtunnel/.QcrilMsgTunnelService in 238764ms
05-14 11:50:48.556  3333  3333 I octvm_whetstone: mcd: can't request the same  mode continuously
05-14 11:50:48.556  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.556  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.556  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.562  1473  1743 I ActivityManager: Process com.qti.service.colorservice (pid 27091) has died
05-14 11:50:48.562  1473  1743 D ActivityManager: cleanUpApplicationRecord -- 27091
05-14 11:50:48.566  1473  1743 W ActivityManager: Scheduling restart of crashed service com.qti.service.colorservice/.ColorServiceApp in 248748ms
05-14 11:50:48.567  3333  3403 I octvm_whetstone: mcd: can't request the same  mode continuously
05-14 11:50:48.567  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.567  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.567  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.629  1473  2126 I ActivityManager: Process com.qualcomm.qti.telephonyservice (pid 28635) has died
05-14 11:50:48.629  1473  2126 D ActivityManager: cleanUpApplicationRecord -- 28635
05-14 11:50:48.629  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.629  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.629  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.633  1473  2126 W ActivityManager: Scheduling restart of crashed service com.qualcomm.qti.telephonyservice/.QtiTelephonyService in 258681ms
05-14 11:50:48.634  1473  1491 I ActivityManager: Process com.android.smspush (pid 28850) has died
05-14 11:50:48.634  1473  1491 D ActivityManager: cleanUpApplicationRecord -- 28850
05-14 11:50:48.635  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.635  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.635  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.638  1473  1491 W ActivityManager: Scheduling restart of crashed service com.android.smspush/.WapPushManager in 268676ms
05-14 11:50:48.639  1473  2028 I ActivityManager: Process com.google.android.googlequicksearchbox:interactor (pid 28365) has died
05-14 11:50:48.639  1473  2028 D ActivityManager: cleanUpApplicationRecord -- 28365
05-14 11:50:48.640  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.640  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.640  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.643  1473  2028 W ActivityManager: Scheduling restart of crashed service com.google.android.googlequicksearchbox/com.google.android.voiceinteraction.GsaVoiceInteractionService in 278671ms
05-14 11:50:48.647  1473  1928 I ActivityManager: Process com.miui.analytics (pid 26242) has died
05-14 11:50:48.647  1473  1928 D ActivityManager: cleanUpApplicationRecord -- 26242
05-14 11:50:48.649  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.649  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.649  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.651  1473  1928 W ActivityManager: Scheduling restart of crashed service com.miui.analytics/.AnalyticsService in 288664ms
05-14 11:50:48.654  1968  1968 I Analytics-Api-SysAnalytics: onServiceDisconnected, pid:1968, tid:1968
05-14 11:50:48.655  1968  1968 I WhetstoneProvider_PersistManager: I MyServiceConnection onServiceDisconnected:ComponentInfo{com.miui.systemAdSolution/com.miui.systemAdSolution.splashscreen.SplashScreenService}
05-14 11:50:48.655  1473  1928 W ActivityManager: Scheduling restart of crashed service com.miui.analytics/.internal.WakeupService in 298659ms
05-14 11:50:48.659  1473  1928 W ActivityManager: Scheduling restart of crashed service com.miui.analytics/.AppenderService in 308656ms
05-14 11:50:48.661  1968  2067 D MemController: receive the low memory message
05-14 11:50:48.661  1968  2067 D MemController: Enter the low memory mode transfer level = 0
05-14 11:50:48.661  1968  2067 D MemController: handle low memory duration time is not enough ignore
05-14 11:50:48.745  1473  2391 I ActivityManager: Process myapp.myapp (pid 28760) has died
05-14 11:50:48.745  1473  2391 D ActivityManager: cleanUpApplicationRecord -- 28760
05-14 11:50:48.746  1473  2021 D GraphicsStats: Buffer count: 1
05-14 11:50:48.757  1473  2124 I WindowState: WIN DEATH: Window{11ef394 u0 SurfaceView}
05-14 11:50:48.768  1473  2391 W ActivityManager: Force removing ActivityRecord{9777e7d u0 myapp.myapp/.MainActivity t47}: app died, no saved state
05-14 11:50:48.806   745   916 W XTCC-5.1.0.16: [CS-RIL-LISTENER] timerCallback fired for ril update registering, re-register
05-14 11:50:48.850  1473  1507 D PowerKeeperPolicy: release all sensors for pid 28760
05-14 11:50:48.859  3774  3774 D wpa_supplicant: wlan0: Control interface command 'SIGNAL_POLL'
05-14 11:50:48.867 28848 28882 W dex2oat : Compilation of void com.google.android.music.sync.common.LoggingThreadedSyncAdapter.<init>(android.content.Context, boolean) took 101.303ms
05-14 11:50:48.872  1473  1639 W InputDispatcher: channel 'e397b10 myapp.myapp/myapp.myapp.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
05-14 11:50:48.872  1473  1639 E InputDispatcher: channel 'e397b10 myapp.myapp/myapp.myapp.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
05-14 11:50:48.874   681   681 W cnss_diag: type=1400 audit(0.0:120841): avc: denied { read } for name="primary" dev="tmpfs" ino=21294 scontext=u:r:wcnss_service:s0 tcontext=u:object_r:mnt_user_file:s0 tclass=lnk_file permissive=0
05-14 11:50:48.874   681   681 W cnss_diag: type=1400 audit(0.0:120842): avc: denied { read } for name="primary" dev="tmpfs" ino=21294 scontext=u:r:wcnss_service:s0 tcontext=u:object_r:mnt_user_file:s0 tclass=lnk_file permissive=0
05-14 11:50:48.892  3774  3774 D wpa_supplicant: CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=229376 outq=0 send_len=48
05-14 11:50:48.900  1473  2082 I WindowState: WIN DEATH: Window{dcfe3d u0 SurfaceView}
05-14 11:50:48.911  1473  2021 I WindowState: WIN DEATH: Window{3bd0632 u0 SurfaceView}
05-14 11:50:48.918  1473  1490 I WindowState: WIN DEATH: Window{c0b0f83 u0 SurfaceView}
05-14 11:50:48.923  1473  2027 I WindowState: WIN DEATH: Window{1c1b500 u0 SurfaceView}
05-14 11:50:48.933  1473  2392 I WindowState: WIN DEATH: Window{e397b10 u0 myapp.myapp/myapp.myapp.MainActivity}
05-14 11:50:48.933  1473  2392 W InputDispatcher: Attempted to unregister already unregistered input channel 'e397b10 myapp.myapp/myapp.myapp.MainActivity (server)'
05-14 11:50:48.966  3434  3437 E ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
05-14 11:50:48.986  1968  2067 D WtProcessController: onAMRestartActivity callback
05-14 11:50:48.987  1473  2391 I PackageManager: com.google.android.youtube mDexOptPerformed=[Ljava.lang.Object;@2a04139
05-14 11:50:48.987  1473  2391 I PackageManager: com.qualcomm.qti.auth.sampleextauthservice mDexOptPerformed=[Ljava.lang.Object;@d31537e
05-14 11:50:48.987  1473  2391 I PackageManager: com.qrd.omadownload mDexOptPerformed=[Ljava.lang.Object;@6e520df
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.providers.telephony mDexOptPerformed=[Ljava.lang.Object;@b0d212c
05-14 11:50:48.987  1473  2391 I PackageManager: com.miui.powerkeeper mDexOptPerformed=[Ljava.lang.Object;@8bab7f5
05-14 11:50:48.987  1473  2391 I PackageManager: com.google.android.googlequicksearchbox mDexOptPerformed=[Ljava.lang.Object;@80b298a
05-14 11:50:48.987  1473  2391 I PackageManager: com.miui.fm mDexOptPerformed=[Ljava.lang.Object;@e24ebfb
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.providers.calendar mDexOptPerformed=[Ljava.lang.Object;@4c12418
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.providers.media mDexOptPerformed=[Ljava.lang.Object;@1cbde71
05-14 11:50:48.987  1473  2391 I PackageManager: com.milink.service mDexOptPerformed=[Ljava.lang.Object;@dfa5456
05-14 11:50:48.987  1473  2391 I PackageManager: com.touchtype.swiftkey mDexOptPerformed=[Ljava.lang.Object;@9cc4cd7
05-14 11:50:48.987  1473  2391 I PackageManager: com.qti.service.colorservice mDexOptPerformed=[Ljava.lang.Object;@b069c4
05-14 11:50:48.987  1473  2391 I PackageManager: com.google.android.onetimeinitializer mDexOptPerformed=[Ljava.lang.Object;@ceef0ad
05-14 11:50:48.987  1473  2391 I PackageManager: com.securespaces.android.sscm.service mDexOptPerformed=[Ljava.lang.Object;@1df5fe2
05-14 11:50:48.987  1473  2391 I PackageManager: com.qualcomm.qti.modemtestmode mDexOptPerformed=[Ljava.lang.Object;@61edf73
05-14 11:50:48.987  1473  2391 I PackageManager: com.xiaomi.account mDexOptPerformed=[Ljava.lang.Object;@92c5e30
05-14 11:50:48.987  1473  2391 I PackageManager: com.qualcomm.shutdownlistner mDexOptPerformed=[Ljava.lang.Object;@5b6eaa9
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.wallpapercropper mDexOptPerformed=[Ljava.lang.Object;@217982e
05-14 11:50:48.987  1473  2391 I PackageManager: com.quicinc.cne.CNEService mDexOptPerformed=[Ljava.lang.Object;@5fdffcf
05-14 11:50:48.987  1473  2391 I PackageManager: com.wt.secret_code_manager mDexOptPerformed=[Ljava.lang.Object;@a312d5c
05-14 11:50:48.987  1473  2391 I PackageManager: org.simalliance.openmobileapi.service mDexOptPerformed=[Ljava.lang.Object;@3ea8865
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.updater mDexOptPerformed=[Ljava.lang.Object;@389093a
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.documentsui mDexOptPerformed=[Ljava.lang.Object;@f04c9eb
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.galaxy4 mDexOptPerformed=[Ljava.lang.Object;@151c348
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.externalstorage mDexOptPerformed=[Ljava.lang.Object;@b0045e1
05-14 11:50:48.987  1473  2391 I PackageManager: com.android.htmlviewer mDexOptPerformed=[Ljava.lang.Object;@16e7f06
05-14 11:50:48.987  1473  2391 I PackageManager: com.qualcomm.svi mDexOptPerformed=[Ljava.lang.Object;@b6419c7
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.securityadd mDexOptPerformed=[Ljava.lang.Object;@63cbf4
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.gallery mDexOptPerformed=[Ljava.lang.Object;@55a5f1d
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.mms.service mDexOptPerformed=[Ljava.lang.Object;@de38592
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.providers.downloads mDexOptPerformed=[Ljava.lang.Object;@d7e8b63
05-14 11:50:48.988  1473  2391 I PackageManager: com.qualcomm.qti.auth.sampleauthenticatorservice mDexOptPerformed=[Ljava.lang.Object;@eebb360
05-14 11:50:48.988  1473  2391 I PackageManager: com.xiaomi.payment mDexOptPerformed=[Ljava.lang.Object;@742d019
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.securitycenter mDexOptPerformed=[Ljava.lang.Object;@f3068de
05-14 11:50:48.988  1473  2391 I PackageManager: com.qualcomm.qti.telephonyservice mDexOptPerformed=[Ljava.lang.Object;@1447abf
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.browser mDexOptPerformed=[Ljava.lang.Object;@648a58c
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.systemAdSolution mDexOptPerformed=[Ljava.lang.Object;@5a754d5
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.videoplayer mDexOptPerformed=[Ljava.lang.Object;@5d634ea
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.providers.applications mDexOptPerformed=[Ljava.lang.Object;@75003db
05-14 11:50:48.988  1473  2391 I PackageManager: com.qualcomm.qti.auth.fidocryptoservice mDexOptPerformed=[Ljava.lang.Object;@4a08e78
05-14 11:50:48.988  1473  2391 I PackageManager: com.google.android.configupdater mDexOptPerformed=[Ljava.lang.Object;@c956951
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.soundrecorder mDexOptPerformed=[Ljava.lang.Object;@75ab5b6
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.defcontainer mDexOptPerformed=[Ljava.lang.Object;@5c102b7
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.guardprovider mDexOptPerformed=[Ljava.lang.Object;@28c1a24
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.providers.downloads.ui mDexOptPerformed=[Ljava.lang.Object;@176498d
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.vending mDexOptPerformed=[Ljava.lang.Object;@9d47742
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.pacprocessor mDexOptPerformed=[Ljava.lang.Object;@ad91353
05-14 11:50:48.988  1473  2391 I PackageManager: com.qualcomm.cabl mDexOptPerformed=[Ljava.lang.Object;@782b490
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.backup mDexOptPerformed=[Ljava.lang.Object;@d0af189
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.certinstaller mDexOptPerformed=[Ljava.lang.Object;@c36c58e
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.carrierconfig mDexOptPerformed=[Ljava.lang.Object;@d5791af
05-14 11:50:48.988  1473  2391 I PackageManager: com.google.android.marvin.talkback mDexOptPerformed=[Ljava.lang.Object;@90689bc
05-14 11:50:48.988  1473  2391 I PackageManager: org.codeaurora.bluetooth mDexOptPerformed=[Ljava.lang.Object;@9281d45
05-14 11:50:48.988  1473  2391 I PackageManager: com.qti.qualcomm.datastatusnotification mDexOptPerformed=[Ljava.lang.Object;@75dac9a
05-14 11:50:48.988  1473  2391 I PackageManager: android mDexOptPerformed=[Ljava.lang.Object;@69599cb
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.contacts mDexOptPerformed=[Ljava.lang.Object;@9085a8
05-14 11:50:48.988  1473  2391 I PackageManager: com.qualcomm.wfd.service mDexOptPerformed=[Ljava.lang.Object;@e3248c1
05-14 11:50:48.988  1473  2391 I PackageManager: com.miui.securitycore mDexOptPerformed=[Ljava.lang.Object;@3d9f866
05-14 11:50:48.988  1473  2391 I PackageManager: com.qualcomm.qti.GBAHttpAuthentication.auth mDexOptPerformed=[Ljava.lang.Object;@26207a7
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.mms mDexOptPerformed=[Ljava.lang.Object;@43c5454
05-14 11:50:48.988  1473  2391 I PackageManager: com.android.stk mDexOptPerformed=[Ljava.lang.Object;@c59affd
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.backupconfirm mDexOptPerformed=[Ljava.lang.Object;@7d34f2
05-14 11:50:48.989  1473  2391 I PackageManager: com.xiaomi.simactivate.service mDexOptPerformed=[Ljava.lang.Object;@9d7743
05-14 11:50:48.989  1473  2391 I PackageManager: com.mfashiongallery.emag mDexOptPerformed=[Ljava.lang.Object;@e3461c0
05-14 11:50:48.989  1473  2391 I PackageManager: com.miui.player mDexOptPerformed=[Ljava.lang.Object;@c964ef9
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.provision mDexOptPerformed=[Ljava.lang.Object;@5a5ae3e
05-14 11:50:48.989  1473  2391 I PackageManager: org.codeaurora.ims mDexOptPerformed=[Ljava.lang.Object;@496449f
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.statementservice mDexOptPerformed=[Ljava.lang.Object;@eddd9ec
05-14 11:50:48.989  1473  2391 I PackageManager: com.google.android.gm mDexOptPerformed=[Ljava.lang.Object;@563e1b5
05-14 11:50:48.989  1473  2391 I PackageManager: com.miui.system mDexOptPerformed=[Ljava.lang.Object;@14a704a
05-14 11:50:48.989  1473  2391 I PackageManager: com.google.android.apps.tachyon mDexOptPerformed=[Ljava.lang.Object;@e248bbb
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.wallpaper.holospiral mDexOptPerformed=[Ljava.lang.Object;@5c4a8d8
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.calendar mDexOptPerformed=[Ljava.lang.Object;@f3de431
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.phasebeam mDexOptPerformed=[Ljava.lang.Object;@7c74716
05-14 11:50:48.989  1473  2391 I PackageManager: com.miui.translation.kingsoft mDexOptPerformed=[Ljava.lang.Object;@8862897
05-14 11:50:48.989  1473  2391 I PackageManager: com.miui.compass mDexOptPerformed=[Ljava.lang.Object;@d477a84
05-14 11:50:48.989  1473  2391 I PackageManager: com.qualcomm.qti.auth.secureextauthservice mDexOptPerformed=[Ljava.lang.Object;@4db926d
05-14 11:50:48.989  1473  2391 I PackageManager: com.google.android.setupwizard mDexOptPerformed=[Ljava.lang.Object;@568bea2
05-14 11:50:48.989  1473  2391 I PackageManager: com.miui.rom mDexOptPerformed=[Ljava.lang.Object;@afab733
05-14 11:50:48.989  1473  2391 I PackageManager: com.qti.primarycardcontroller mDexOptPerformed=[Ljava.lang.Object;@503baf0
05-14 11:50:48.989  1473  2391 I PackageManager: com.qualcomm.qcrilmsgtunnel mDexOptPerformed=[Ljava.lang.Object;@b2be869
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.providers.settings mDexOptPerformed=[Ljava.lang.Object;@cb822ee
05-14 11:50:48.989  1473  2391 I PackageManager: com.android.sharedstoragebackup mDexOptPerformed=[Ljava.lang.Object;@71f938f
05-14 11:50:48.989  1473  2391 I PackageManager: com.mediatek.batterywarning mDexOptPerformed=[Ljava.lang.Object;@701961c
05-14 11:50:48.989  1473  2391 I PackageManager: com.jeejen.knowledge mDexOptPerformed=[Ljava.lang.Object;@d11a225
kesha-antonov commented 7 years ago

Hello @gre ! Have you had time for this feature? Maybe it's easier now to develop?

Maybe I can help? I've encountered crashes on android which is not good... So I think it's better to use gl-react 3 which is actively maintained.

luco commented 7 years ago

+1 on this. It's a must.

gre commented 7 years ago

if you want to help: https://github.com/gre/react-native-webgl/issues/2 gl-react-native is now backed by a new lib i've created (react-native-webgl) and I figured out the API but needs to implement on the back.

I have not planned this yet in my ETA ( https://github.com/gre/gl-react/issues/148 ) but it should comes after the features listed there (unless I find it easy and implement it soon^^)

kesha-antonov commented 7 years ago

@gre Thank you for update!

luco commented 7 years ago

@gre That's amazing! Thanks!

AlexStasse commented 7 years ago

How is progress on this going? I've been trying to use CaptureFrame on v2 but can't get it to work consistently, the object seems to be unloading before the promise returns.

gre commented 7 years ago

technically you can already capture with .capture method ( https://gl-react-cookbook.surge.sh/api#Surface#capture / https://gl-react-cookbook.surge.sh/api#Node#capture ) but however that will only get you a typed array.. so the missing part is we need a React Native library that would take that typed array, encode and save to an image and returns the URI of it. that's what i've commented here: https://github.com/react-community/react-native-webgl/issues/2#issuecomment-328343029

so if you want to investigate on such a library it would be great.

in web you already have the toDataURL() and toBlob() on a canvas, we need an equivalent of that!

AlexStasse commented 7 years ago

Since capture is already calling native code to get the typed array, wouldn't it be better to reuse that code to grab the typed array without returning to react, make that into a file and return the URI? It's probably around 6 lines of native code (in android at least, I haven't touched iOS).

kesha-antonov commented 6 years ago

@AlexStasse Hey! Please share code for Android (working example of modified gl-react) I'll try make same for iOS

kesha-antonov commented 6 years ago

Can we 1) call in native ios/android .capture 2) get pixels array 3) convert to image file 4) pass uri back to js

?

https://stackoverflow.com/questions/7650144/how-to-convert-bytearray-to-image-in-objective-c

gre commented 6 years ago

all from native side you mean? maybe something around that path would work. btw I had this wip: https://github.com/react-community/react-native-webgl/commit/2f31cad1717715d520be1d89c64123678f6db02c

but it was built-in in react-native-webgl which we now try to avoid again the main challenge here is to accept JS native array. the rest is simple.. but maybe if we make an extension to manually call glReadPixels instead of accepting a JS native array it would work? would be very close to the code of that commit then?

the main issue is glReadPixels need to happen at the correct time too. so maybe the best way would be to write that encodeRGBAImagePixelsToFile and it would probably need to be some low level c++ thing so it can access JSC and extract from the typedarray.. that means duplicating some code from that https://github.com/react-community/react-native-webgl/blob/master/cpp/JSConvertTypedArray.c but i don't see another way 🤔

luco commented 6 years ago

Any updates on this?

kesha-antonov commented 6 years ago

Hello guys! Any updates? New libs, new technologies being created which could help us?

@gre Please can you remind why we can't port (or can?) same function from v2?

And is it possible to capture effected video? (potentially)

Did this code work as you expected? https://github.com/react-community/react-native-webgl/commit/2f31cad1717715d520be1d89c64123678f6db02c Did it create effected image?

gre commented 6 years ago

basically haven't progress much since my last comment. the code was working (iOS only) but it was more a matter of make this library only focusing on WebGL and the ideal idea that it would be more powerful if we would be able to implement a lib that takes a UInt8Array and turns that into an image file (a library that do JUST that would be very useful, and not only for this library, kinda like in the "unix" philosophy). the current hard part at the moment is it's not so trivial to have such library because RN don't yet have native array support out of the box. Now pragmatically we could follow that temporary path to have such feature build-in this library and eventually try to move it out.

I'm not actively working on react-native-webgl at the moment, I hope it eventually gets more help from the community and especially devs of react-community github group.. on my "gl-react side" it's easy because this side is just JavaScript so it will be a matter of hooking things when it gets implemented in react-native-webgl