fade is broken

Issue #37 resolved
Benjamin Hoffmann created an issue

It seems that the fade function is broken on the last version.

process int main()
begin

    set_mode(640, 480);
    set_fps(60, 0);

    fade(255, 0, 0, 1);  // It should fade to red but nothing append

    while(!key(_esc))
        frame;
    end
end

(Sorry for reporting all what I see, but I think it can be useful. I know you can not resolve all the bug quickly, but I prefer to report to be sure nothing is lost)

Comments (19)

  1. Joseba Echevarria García repo owner

    I can confirm the issue.

    The following code is your code with the imports explicitly written:

    import "mod_key"
    import "mod_video"
    import "mod_map"
    
    process int main()
    begin
    
        set_mode(640, 480);
        set_fps(60, 0);
    
        fade(255, 0, 0, 1);  // It should fade to red but nothing append
    
        while(!key(_esc))
            frame;
        end
    end
    

    I'll fix it ASAP.

  2. Benjamin Hoffmann reporter

    Do you know if this bug is hard to fix ? I'm about to release a game but this is the only bug remaining ! :)

  3. Joseba Echevarria García repo owner

    I cannot say for sure, but I'd try to fix this within a couple of days.

  4. Joseba Echevarria García repo owner

    OK, I've uploaded commits 4cd7d54 & a418b25 which includes a dirty hack to emulate fades. The problem here is that in order to correctly implement Bennu's FADE function I need to use shaders and I'm not using them as of now.

    As long as you fade.in and out to/from the same colour, things should work approximately right BUT this is not the same implementation that BennuGD uses. I'm only alpha-blending a filled rectangle of the size of the window.

    Now, there's more drawbacks: I've had to change the behaviour of the fade function. It now works as follows:

    FADE(int r, int g, int b, int a, int speed);
    

    So you must specify the alpha value you're going to be fading to. So, to fade into red and back you'd do:

    import "mod_video"
    import "mod_map"
    
    process int main()
    begin
        set_mode(640, 480);
        set_fps(60, 0);
    
        // Put something onscreen to appreciate the fade
        graph = png_load("imshow.png");
        x = 320;
        y = 240;
        size = 50;
    
        fade(255, 0, 0, 255, 1);
    
        while(fading)
            frame;
        end
    
        fade(255, 0, 0, 0, 1);
        while(fading)
            frame;
        end
    end
    

    On BennuGD, r, g & b go 0-200 and they have special meanings; here they're just colour components.

    Sorry it's not a real fix; hope it helps...

  5. Joseba Echevarria García repo owner

    Cool.

    You can try different values of the SDL_SetRenderDrawBlendMode function in modules/librender/g_fade.c to change the effect. Possible values are defined here. SDL_BLENDMODE_ADD might work, too.

    I'm going to declare the bug as partially solved since I don't think there's much more that I can do about it without implementing shaders...

  6. Joseba Echevarria García repo owner

    Sorry to hear that. I'll try to fix it tomorrow. I want to see your game :)

  7. Joseba Echevarria García repo owner
    • changed status to open

    I cannot seem to replicate the bug. The following code works perfectly for me:

    import "mod_video"
    import "mod_map"
    
    process int main()
    begin
        // Put something onscreen to appreciate the fade
        graph = png_load("lemniscata.png");
        x = graphic_info(0, -1, G_WIDTH)/2;
        y = graphic_info(0, -1, G_HEIGHT)/2;
    
        fade(255, 0, 0, 255, 1);
    
        while(fading)
            frame;
        end
    
        fade(255, 0, 0, 0, 1);
        while(fading)
            frame;
        end
    end
    

    Could you post your logcat output?

  8. Benjamin Hoffmann reporter

    I can replicate the bug with your code. Here is my logcat :

    --------- beginning of main
    
    I/thermal_repeater(  309): oh, queryMdThermalInfo (0)Bad file number
    
    I/thermal_repeater(  309): [recvMdThermalInfo] ret=27, strLen=127,  3, 23, -127, -1, 32767, 17
    
    --------- beginning of system
    
    I/auditd  (23928): Starting up
    
    E/audit_log(23928): Could not stat audit logfile /data/misc/audit/audit.log: Permission denied
    
    E/auditd  (23928): Failed on audit_log_open
    
    I/auditd  (23928): Exiting
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f99d11fa0 ID=15109 fd=38 ref=1 1080(1088)x1920-0x1 usage=0xb00 size=8355840(8355840) cache=0
    
    D/GraphicBuffer(  256): alloc, handle(0x7f99d11fa0) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00) err(0)
    
    D/IMGSRV  ( 1387): gralloc_register_buffer:1390: hnd=0x7f69bf81a0 ID=15109 fd=55 ref=1
    
    D/GraphicBuffer( 1387): register, handle(0x7f69bf81a0) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/AALLightSensor(  288): newLux = 30, [30, 30] -> 30
    
    I/Timeline( 1387): Timeline: Activity_launch_request id:org.pixtudio.samplegame time:9335902
    
    I/ActivityManager(  655): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.pixtudio.samplegame/.MyGame (has extras)} from uid 10077 on display 0
    
    V/WindowManager(  655): addAppToken: AppWindowToken{dfbdfbf token=Token{3a4241de ActivityRecord{8806d19 u0 org.pixtudio.samplegame/.MyGame t104}}} to stack=1 task=104 at 0
    
    V/WindowManager(  655): Adding window Window{29a1c1d5 u0 Starting org.pixtudio.samplegame} at 13 of 17 (after Window{2e621326 u0 com.google.android.talk/com.google.android.apps.hangouts.phone.ConversationActivity})
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f994243e0 ID=15110 fd=57 ref=1 1080(1088)x1920-0x2 usage=0x933 size=8355840(8355840) cache=1
    
    D/GraphicBuffer(  256): alloc, handle(0x7f994243e0) (w:1080 h:1920 s:1088 f:0x2 u:0x000933) err(0)
    
    D/IMGSRV  (  655): gralloc_register_buffer:1390: hnd=0x7f7814c940 ID=15110 fd=309 ref=1
    
    D/GraphicBuffer(  655): register, handle(0x7f7814c940) (w:1080 h:1920 s:1088 f:0x2 u:0x000933)
    
    I/ActivityManager(  655): Start proc 23930:org.pixtudio.samplegame/u0a137 for activity org.pixtudio.samplegame/.MyGame
    
    I/art     (23930): Late-enabling -Xcheck:jni
    
    V/WindowManager(  655): rotationForOrientationLw(orient=1, last=0); user=0 
    
    D/FrameworkListener(  274): dispatchCommand data = (getaddrinfo www.googleadservices.com ^ 1024 0 1 0 0)
    
    D/GraphicBuffer( 1387): unregister, handle(0x7f5de26ec0) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/IMGSRV  ( 1387): gralloc_unregister_buffer:1503: ID=15103 ref=0
    
    D/GraphicBuffer( 1387): unregister, handle(0x7f5dca7260) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/IMGSRV  ( 1387): gralloc_unregister_buffer:1503: ID=15108 ref=0
    
    D/GraphicBuffer( 1387): unregister, handle(0x7f69bf81a0) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/IMGSRV  ( 1387): gralloc_unregister_buffer:1503: ID=15109 ref=0
    
    D/GraphicBuffer(  256): free, handle(0x7f99d5dd40) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/IMGSRV  (  256): gralloc_device_free:1251: ID=15108 ref=0
    
    V/PixTudio(23930): Device: hennessy
    
    V/PixTudio(23930): Model: Redmi Note 3
    
    D/GraphicBuffer(  256): free, handle(0x7f99d11fa0) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/IMGSRV  (  256): gralloc_device_free:1251: ID=15109 ref=0
    
    V/WindowManager(  655): Adding window Window{2ccee590 u0 org.pixtudio.samplegame/org.pixtudio.samplegame.MyGame} at 13 of 18 (before Window{29a1c1d5 u0 Starting org.pixtudio.samplegame})
    
    D/SocketClient(  274): SocketClient sendData done: 222
    
    D/SocketClient(  274): SocketClient sendData done: 
    
    D/SocketClient(  274): SocketClient sendData done: 
    
    D/SocketClient(  274): SocketClient sendData done: 
    
    D/SocketClient(  274): SocketClient sendData done: 
    
    D/SocketClient(  274): SocketClient sendData done: 
    
    D/SocketClient(  274): SocketClient sendData done: 
    
    V/WindowManager(  655): Adding window Window{ff0de8e u0 SurfaceView} at 13 of 19 (before Window{2ccee590 u0 org.pixtudio.samplegame/org.pixtudio.samplegame.MyGame})
    
    D/SocketClient(  274): SocketClient sendData done: 
    
    E/GoogleConversionReporter(22208): Error sending ping
    
    E/GoogleConversionReporter(22208): java.net.ConnectException: failed to connect to www.googleadservices.com/127.0.0.1 (port 443) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused)
    
    E/GoogleConversionReporter(22208):  at libcore.io.IoBridge.isConnected(IoBridge.java:238)
    
    E/GoogleConversionReporter(22208):  at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
    
    E/GoogleConversionReporter(22208):  at libcore.io.IoBridge.connect(IoBridge.java:122)
    
    E/GoogleConversionReporter(22208):  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
    
    E/GoogleConversionReporter(22208):  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456)
    
    E/GoogleConversionReporter(22208):  at java.net.Socket.connect(Socket.java:882)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.Platform.connectSocket(Platform.java:174)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.Connection.connect(Connection.java:152)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
    
    E/GoogleConversionReporter(22208):  at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
    
    E/GoogleConversionReporter(22208):  at bkx.a(SourceFile:230)
    
    E/GoogleConversionReporter(22208):  at bla.run(SourceFile:174)
    
    E/GoogleConversionReporter(22208):  at java.lang.Thread.run(Thread.java:818)
    
    E/GoogleConversionReporter(22208): Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
    
    E/GoogleConversionReporter(22208):  at libcore.io.IoBridge.isConnected(IoBridge.java:223)
    
    E/GoogleConversionReporter(22208):  ... 17 more
    
    V/SDL     (23930): pixel format RGB_565
    
    V/SDL     (23930): Window size: 1080x1920
    
    E/Sensors (  655): handleToDriver handle(0)
    
    D/Accel   (  655): setDelay: (handle=0, ns=20000000)
    
    E/Sensors (  655): new setDelay handle(0),ns(20000000)m, error(0), index(2)
    
    E/Sensors (  655): handleToDriver handle(0)
    
    D/Accel   (  655): setDelay: (handle=0, ns=20000000)
    
    E/Sensors (  655): new setDelay handle(0),ns(20000000)m, error(0), index(2)
    
    I/SDL     (23930): SDL_Android_Init()
    
    I/SDL     (23930): SDL_Android_Init() finished!
    
    I/SDL/APP (23930): BennuGD init
    
    I/SDL/APP (23930): Loading main.dcb from the APK...
    
    D/AALService(  288): enableAALEvent: 0 -> 1
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f99d10b60 ID=15115 fd=38 ref=1 1080(1088)x1920-0x1 usage=0x933 size=8355840(8355840) cache=1
    
    D/GraphicBuffer(  256): alloc, handle(0x7f99d10b60) (w:1080 h:1920 s:1088 f:0x1 u:0x000933) err(0)
    
    D/Terminal(19705): resize(31, 67, 100)
    
    D/IMGSRV  (23930): gralloc_register_buffer:1390: hnd=0xf4edc520 ID=15115 fd=31 ref=1
    
    D/GraphicBuffer(23930): register, handle(0xf4edc520) (w:1080 h:1920 s:1088 f:0x1 u:0x000933)
    
    D/IMGSRV  (23930): gralloc_module_getimplementationformat:2526: usage=0x1000 > fmt=0x1
    
    D/IMGSRV  (23930): gralloc_module_getimplementationformat:2526: usage=0x1000 > fmt=0x1
    
    D/IMGSRV  (23930): gralloc_module_getimplementationformat:2526: usage=0x1000 > fmt=0x1
    
    D/IMGSRV  (23930): gralloc_module_getimplementationformat:2526: usage=0x1000 > fmt=0x1
    
    D/IMGSRV  (23930): gralloc_module_getimplementationformat:2526: usage=0x1000 > fmt=0x1
    
    I/ActivityManager(  655): Displayed org.pixtudio.samplegame/.MyGame: +210ms
    
    I/Keyboard.Facilitator( 1212): onFinishInput()
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f99e751a0 ID=15169 fd=47 ref=1 1080(1088)x1920-0x4 usage=0xb00 size=4177920(4177920) cache=0
    
    D/GraphicBuffer(  256): alloc, handle(0x7f99e751a0) (w:1080 h:1920 s:1088 f:0x4 u:0x000b00) err(0)
    
    D/IMGSRV  (23930): gralloc_register_buffer:1390: hnd=0xef1343a0 ID=15169 fd=38 ref=1
    
    D/GraphicBuffer(23930): register, handle(0xef1343a0) (w:1080 h:1920 s:1088 f:0x4 u:0x000b00)
    
    I/Timeline(23930): Timeline: Activity_idle id: android.os.BinderProxy@3470e53c time:9336195
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f99e75200 ID=15201 fd=49 ref=1 1080(1088)x1920-0x4 usage=0xb00 size=4177920(4177920) cache=0
    
    D/GraphicBuffer(  256): alloc, handle(0x7f99e75200) (w:1080 h:1920 s:1088 f:0x4 u:0x000b00) err(0)
    
    D/IMGSRV  (23930): gralloc_register_buffer:1390: hnd=0xef134640 ID=15201 fd=41 ref=1
    
    D/GraphicBuffer(23930): register, handle(0xef134640) (w:1080 h:1920 s:1088 f:0x4 u:0x000b00)
    
    E/SDL/APP (23930): ERROR: Runtime error in MAIN(65536) - Unknown system process
    
    D/GraphicBuffer(  655): unregister, handle(0x7f7814c940) (w:1080 h:1920 s:1088 f:0x2 u:0x000933)
    
    D/IMGSRV  (  655): gralloc_unregister_buffer:1503: ID=15110 ref=0
    
    D/GuiExt  (  314): [GuiExtS] binder of dump tunnel(RB-0xf4f03498) died
    
    W/InputDispatcher(  655): channel '2ccee590 org.pixtudio.samplegame/org.pixtudio.samplegame.MyGame (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
    
    E/InputDispatcher(  655): channel '2ccee590 org.pixtudio.samplegame/org.pixtudio.samplegame.MyGame (server)' ~ Channel is unrecoverably broken and will be disposed!
    
    E/Sensors (  655): handleToDriver handle(0)
    
    D/Accel   (  655): setDelay: (handle=0, ns=66667000)
    
    E/Sensors (  655): new setDelay handle(0),ns(66667000)m, error(0), index(2)
    
    I/ActivityManager(  655): Process org.pixtudio.samplegame (pid 23930) has died
    
    W/ActivityManager(  655): Force removing ActivityRecord{8806d19 u0 org.pixtudio.samplegame/.MyGame t104}: app died, no saved state
    
    I/WindowState(  655): WIN DEATH: Window{2ccee590 u0 org.pixtudio.samplegame/org.pixtudio.samplegame.MyGame}
    
    W/InputDispatcher(  655): Attempted to unregister already unregistered input channel '2ccee590 org.pixtudio.samplegame/org.pixtudio.samplegame.MyGame (server)'
    
    I/WindowState(  655): WIN DEATH: Window{ff0de8e u0 SurfaceView}
    
    V/WindowManager(  655): rotationForOrientationLw(orient=5, last=0); user=0 
    
    D/GraphicBuffer(  256): free, handle(0x7f994243e0) (w:1080 h:1920 s:1088 f:0x2 u:0x000933)
    
    D/IMGSRV  (  256): gralloc_device_free:1251: ID=15110 ref=0
    
    I/PerfService(  256): PerfServiceNative_notifyDisplayType:0
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f99d5db60 ID=15204 fd=77 ref=1 1080(1088)x1920-0x1 usage=0xb00 size=8355840(8355840) cache=0
    
    D/GraphicBuffer(  256): alloc, handle(0x7f99d5db60) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00) err(0)
    
    D/IMGSRV  ( 1387): gralloc_register_buffer:1390: hnd=0x7f6744d220 ID=15204 fd=54 ref=1
    
    D/GraphicBuffer( 1387): register, handle(0x7f6744d220) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f99424380 ID=15205 fd=92 ref=1 1080(1088)x1920-0x1 usage=0xb00 size=8355840(8355840) cache=0
    
    D/GraphicBuffer(  256): alloc, handle(0x7f99424380) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00) err(0)
    
    D/Terminal(19705): resize(27, 67, 100)
    
    I/PerfService(  256): PerfServiceNative_notifyDisplayType:1
    
    D/IMGSRV  (  256): gralloc_device_alloc:1102: hnd=0x7f994241a0 ID=15206 fd=72 ref=1 1080(1088)x1920-0x1 usage=0xb00 size=8355840(8355840) cache=0
    
    D/GraphicBuffer(  256): alloc, handle(0x7f994241a0) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00) err(0)
    
    I/Timeline(  655): Timeline: Activity_windows_visible id: ActivityRecord{8806d19 u0 org.pixtudio.samplegame/.MyGame t104 f} time:9336490
    
    D/GraphicBuffer(  256): free, handle(0x7f99d10b60) (w:1080 h:1920 s:1088 f:0x1 u:0x000933)
    
    D/IMGSRV  (  256): gralloc_device_free:1251: ID=15115 ref=0
    
    D/GraphicBuffer(  256): free, handle(0x7f99e75200) (w:1080 h:1920 s:1088 f:0x4 u:0x000b00)
    
    D/IMGSRV  (  256): gralloc_device_free:1251: ID=15201 ref=0
    
    D/GraphicBuffer(  256): free, handle(0x7f99e751a0) (w:1080 h:1920 s:1088 f:0x4 u:0x000b00)
    
    D/IMGSRV  (  256): gralloc_device_free:1251: ID=15169 ref=0
    
    W/InputMethodManagerService(  655): Got RemoteException sending setActive(false) notification to pid 23930 uid 10137
    
    I/Keyboard.Facilitator( 1212): onFinishInput()
    
    I/Timeline( 1387): Timeline: Activity_idle id: android.os.BinderProxy@3e12c645 time:9336528
    
    D/GraphicBuffer(  256): free, handle(0x7f99d5e3a0) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    D/IMGSRV  (  256): gralloc_device_free:1251: ID=15103 ref=0
    
    W/LocationOracle(13376): Best location was null
    
    D/AALService(  288): enableAALEvent: 1 -> 0
    
    I/Timeline(  655): Timeline: Activity_windows_visible id: ActivityRecord{55e3da3 u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL t74} time:9336690
    
    D/IMGSRV  ( 1387): gralloc_register_buffer:1390: hnd=0x7f69bf8740 ID=15205 fd=64 ref=1
    
    D/GraphicBuffer( 1387): register, handle(0x7f69bf8740) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
    
    W/ResourceType(  832): No package identifier when getting value for resource number 0x00000000
    
    W/PackageManager(  832): Failure retrieving resources for org.pixtudio.samplegame: Resource ID #0x0
    
    I/NewsWeather(22162): Last usage 0, idle 1461775476 seconds, sync interval 2160000 seconds
    
    I/NewsWeather(22162): Last usage 0, idle 1461775476 seconds, sync interval 2160000 seconds
    
    I/NewsWeather(22162): setPeriodicSync in 2160000 seconds
    
    I/NewsWeather(22162): Last usage 1461303769645, idle 471706 seconds, sync interval 86400 seconds
    
    I/NewsWeather(22162): Last usage 1461303769645, idle 471706 seconds, sync interval 86400 seconds
    
    I/NewsWeather(22162): setPeriodicSync in 86400 seconds
    
    I/NewsWeather(22162): Last usage 0, idle 1461775476 seconds, sync interval 2160000 seconds
    
    I/NewsWeather(22162): Last usage 0, idle 1461775476 seconds, sync interval 2160000 seconds
    
    I/NewsWeather(22162): setPeriodicSync in 2160000 seconds
    
  9. Joseba Echevarria García repo owner

    Well, that line saying:

    E/SDL/APP (23930): ERROR: Runtime error in MAIN(65536) - Unknown system process
    

    is certainly intriguing. Could you please send me a copy of the APK you got? (with the source code). I know you said that you just run the example I posted, but it might help somehow...

    Thanks!

  10. Joseba Echevarria García repo owner

    I can replicate the issue with your DCB directly from Linux. It might be related to not using the same version of PixTudio in your desktop (for compiling main.dcb) as you're using in Android. Is that the case?

    (If that is, indeed, the case, please note that I've updated the build instructions in pixtudio.org and you now need ninja for building).

  11. Benjamin Hoffmann reporter

    Ho yes I'm sorry, you are right, my Android version was not up to date. It works now, you can close the thread. Sorry again !

  12. Log in to comment