blitz-foundation / monkey2

zlib License
3 stars 0 forks source link

Android (Threads vs None) Release vs Debug differences #BUG #88

Open Pharmhaus-2 opened 5 years ago

Pharmhaus-2 commented 5 years ago

Original Author: Ghouly-The-Ghost

Bug Details

Develop Branch (Jul 26, 2018) Mx2cc version 1.1.15 MSVC x64 - Updated Bugged Export: Android Release W/ Threads

Synopsis:

My project is about 1,569 LOC. It works perfectly fine and very smooth in the single threaded Android release. With threaded support enabled, it appears that all methods inside of a stack of object-stored functions are iterated through, but only the last function is actually executed. This is strange behavior because on Debug mode, with threads enabled, it works like normal (or appears too)!

Possible Code To Test

Even though my project is big I'm confident to say that this code provided should be testable. Otherwise I can send you my project to test with. But I recommend comparing the results of the following code between (1)Android Single Threaded Release, (2)Android Release Multithreaded Enabled, and (3)Android Debug Multi-threaded Enabled. (2) should not work.

#Import "<std>"

Using std..

Class Holder 

    Field item:Void(ULong)
    Method New( item_:Void(ULong) )
        item=item_
    End

End

Function Testfunc( val:ULong )
    Print "<external function> TestFunc val: " + val
End

Class TestOther

    Method MyMethod( val:ULong )
        Print "<other object method> MyMethod val: " + val
    End

End

Class Test

    Field holders:Stack<Holder>
    Method New()
        holders=New Stack<Holder>

        holders.Add(New Holder( Lambda( val:ULong )
            Print "<lambda> anonymous val: " + val
        End ) )

        holders.Add( New Holder( CallMe ) )

        holders.Add( New Holder( Testfunc ) )

        Local obj:=New TestOther
        holders.Add( New Holder( obj.MyMethod ) )

    End

    Method CallMe( val:ULong )
        Print "<method> CallMe Val: " + val
    End

    Method Run()

        Print ": START LOOP :~n"
        ' Inside a loop
        Local i:=0
        For Local holder:=Eachin holders
            holder.item( 1000 + RndULong() Mod 200 )
            Print "Loop: " + i
            i +=1
        Next

        Print "~n: END LOOP :~n~n~nStarting Normal~n"

        ' Normal Calls
        CallMe( RndULong() Mod 200  )
        Testfunc( RndULong() Mod 200 )
        Local obj:=New TestOther
        obj.MyMethod( RndULong() Mod 200  )

    End
End

Function Main()
    Local test:=New Test
    test.Run()
End